Changing i18n .properties file name

I’m using Babel Edit that outputs and requires the .properties file to be in

en-GB.properties format.

CBi18N module requires

_en_GB.properties format.

I’m not sure what the main part is in the defaultResourceBundle /includes/i18n/main

Is there any way to change the filename that CBi18N requires to load?

Thanks

Tony

Tony,

I’ve used BabelEdit with ColdBox cbi18n sites and have not had that issue. Can you try manually renaming your files, then open them in BabelEdit? In my case, my two files were

main_en_US.json
main_es_ES.json

And BabelEdit was able to manage them fine.

For reference, here are my ColdBox.cfc module settings:

		cbi18n : {
			// The default resource to load and aliased as `default`
			"defaultResourceBundle" : "includes/i18n/main",
			// The locale to use when none defined
			"defaultLocale"         : "en_US",
			// The default storage for the locale
			"localeStorage"         : "cookieStorage@cbstorages",
			// What to emit to via the resource methods if a translation is not found
			"unknownTranslation"    : "**NOT FOUND**",
			// If true, we will log to LogBox the missing translations
			"logUnknownTranslation" : true,
			// A-la-carte resources to load by name
			"resourceBundles"       : {},
			// Your own CFC instantiation path
			"customResourceService" : ""
		},

Hi

Thanks for coming back to me! No, using .properties it seems to have to be en-US.properties and using json the same - en-GB.json.

Coldbox does not like this, which was why I was trying to change the file name. Changing either with Coldbox or with babel edit would be good!

I’m raising a support ticket for this with babel edit - FYI version is 4.0.3.

Thanks

Tony

Tony,

I tried again this morning, and I can use BabelEdit to edit files with this naming convention. I am using generic-json with BabelEdit. Here is what I have. Since I cannot attach files, try copying the contents of each block into a file, put them in the same directory, and then open test.babel in BabelEdit. You should be able to edit the files, keeps those names, and then use them in ColdBox. You can rename the files as needed. I use JSON files and find them easier to work with.

-Daniel

main_en_US.json

{
	"folder": {
		"test2": "Test 2"
	},
	"test": "Test"
}

main_en_GB.json

{
	"folder": {
		"test2": "Test 2"
	},
	"test": "Test"
}

test.babel

<?xml version="1.0" encoding="UTF-8"?>
<babeledit_project be_version="4.0.3" version="1.3">
	<!--

    BabelEdit project file
    https://www.codeandweb.com/babeledit

    This file contains meta data for all translations, but not the translation texts itself.
    They are stored in framework-specific message files (.json / .vue / .yaml / .properties)

    -->
	<preset_collections/>
	<framework>generic-json</framework>
	<filename>test.babel</filename>
	<source_root_dir/>
	<folder_node>
		<name/>
		<children>
			<package_node>
				<name>main</name>
				<children>
					<folder_node>
						<name>folder</name>
						<children>
							<concept_node>
								<name>test2</name>
								<description/>
								<comment/>
								<default_text/>
								<translations>
									<translation>
										<language>en-GB</language>
										<approved>false</approved>
									</translation>
									<translation>
										<language>en-US</language>
										<approved>false</approved>
									</translation>
								</translations>
							</concept_node>
						</children>
					</folder_node>
					<concept_node>
						<name>test</name>
						<description/>
						<comment/>
						<default_text/>
						<translations>
							<translation>
								<language>en-GB</language>
								<approved>false</approved>
							</translation>
							<translation>
								<language>en-US</language>
								<approved>false</approved>
							</translation>
						</translations>
					</concept_node>
				</children>
			</package_node>
		</children>
	</folder_node>
	<isTemplateProject>false</isTemplateProject>
	<languages>
		<language>
			<code>en-GB</code>
		</language>
		<language>
			<code>en-US</code>
		</language>
	</languages>
	<translation_packages>
		<translation_package>
			<name>main</name>
			<translation_urls>
				<translation_url>
					<path>main_en_GB.json</path>
					<language>en-GB</language>
				</translation_url>
				<translation_url>
					<path>main_en_US.json</path>
					<language>en-US</language>
				</translation_url>
			</translation_urls>
		</translation_package>
	</translation_packages>
	<editor_configuration>
		<save_empty_translations>true</save_empty_translations>
		<translation_order>alphabetically</translation_order>
		<copy_templates>
			<copy_template>'%1'</copy_template>
			<copy_template/>
			<copy_template/>
		</copy_templates>
		<custom_languages/>
	</editor_configuration>
	<primary_language/>
	<configuration>
		<indent>tab</indent>
		<format>namespaced-json</format>
		<support_arrays>true</support_arrays>
	</configuration>
</babeledit_project>

Hi Daniel

Sorted it… Thanks for your help - I saw the

                <translation_url>
					<path>main_en_US.json</path>
					<language>en-US</language>
				</translation_url>

This was not present in my Babel Edit config file.

The naming of the output file has to be done in Languages - I let the system create its own file name hence en-US etc.

It’s best to create the file in the format that CBI18N needs and then set it when you are putting in the languages that you need.

Easy when you know how!!

Thanks for your help!

Tony