Greetings
For those of you who use CSV files to localize your projects into multiple languages, I’ve developed an addon that allows you to add and view the values of CSV table reference keys in Nodes (such as ‘Label’, ‘RichTextLabel’, ‘Label3D’, etc.) via their ‘Text’ field, as well as in variables created in scripts.
This would be useful for placing all the keywords in menus, object tabs, dialogs, etc.
The addon is available in the Asset Store. For more detailed documentation, I recommend checking the repository I’ve linked on the page.
Set & See Localization Key Addon
Here are some images:
PD: If you have any suggestions or comments, please feel free to share them here.
1 Like
New version 1.2 available:
-
Adjustments have been made and bugs fixed.
-
And most importantly, a new feature has been added: a new button node, “SetAndSeeButtonEditor”. It’s designed to be added to embedded/floating plugins in the Editor, especially those of the ‘Graph-based’ type, although it would also work with any other plugin integrated into the Editor.
- Now, the language value field in the ‘Set’ and ‘See’ windows supports the ‘BBCode’ format.
I have new features in mind for version 1.3. As you know, you can let me know any questions or suggestions here.
New version 1.3 available:
- In the ‘Set’ window:
-
Left side:
- 'Whole Words CheckButton’, searches for words where only the entire word matches.
- 'Finder Mode OptionButton,’ selects search by key or by File.
- 'Clear Finder Button’, clears the Finder field.
- The 'Expand/Collapse Button’ does this with file headers.
-
Right side:
- Verbum Inser: Inserts the current value from the language text box into the Inspector’s Variable/Node field. This is very useful if you don’t want to enter a reference key, but do want to enter the text in a specific language.
- Vacuus: A shortcut to clear the text entered in the Inspector’s Variable/Node field without having to close the window.
- Plus Setting, allows display of the buttons: line separation, paragraph separation, and horizontal alignment.
- Toggle BBCode format, and Font size.
That’s all for now. When will I release version 1.4? Currently, I want to investigate the ‘?plurals’ and ‘?context’ functions that Godot version 4.6 introduced for CSV files. I’d like to be able to view ‘plurals’ and ‘contexts’ in the windows, but I haven’t yet tested them with a CSV file. So, I don’t know when a version will be available. Regards.
New version 1.4 available:
IMPORTANT: This version works in Godot 4.6 and later.
Changed
- Now in Finder, CSV filenames are sorted alphabetically, as are similar keywords in search results.
- You can now view language names, written in the format ‘Language_Script_COUNTRY_VARIANT’, in the OptionButton for selecting the language in the ‘Set’ and ‘See’ windows. Previously, when a language code like “en_UK” was in the header, it did not appear in the OptionButton, only the individual code like ‘en’, ‘es’, ‘fr’, etc.
Added
- For the special tables to function correctly, certain aspects must be kept in mind:
-
All tables:
IMPORTANT
The first column MUST consist of REFERENCE_KEYS (like standard tables), and not a language. Godot can read special tables whose first column is REFERENCE_KEYS, as well as a language as a reference key, BUT it is easier with REFERENCE_KEYS. The plugin WORKS with the first column consisting of REFERENCE_KEYS; having a language as the first column could cause problems. e.g.:
-
Correct:
| key |
?context |
fr |
ru |
en |
ja |
zh |
| LETTER |
Alphabet |
Lettre |
Буква |
Letter |
字母 |
字母 |
| LETTER |
Message |
Courrier |
Письмо |
Letter |
手紙 |
信件 |
-
Incorrect:
| en |
?context |
fr |
ru |
ja |
zh |
| Letter |
Alphabet |
Lettre |
Буква |
字母 |
字母 |
| Letter |
Message |
Courrier |
Письмо |
手紙 |
信件 |
-
Tables ‘?plural’:
-
The ?pluralrule row is NOT necessary for the plugin (even for Godot). The program already includes the rules for plurals (you can see this in the variable ‘const CODE_PLURAL_LANGUAGE’ and the ‘_apply_language_rule’ method in ‘manage_set_and_see_localization.gd’). ONLY use this row if you want to modify specific rules, but those changes WILL NOT work in the plugin. If you want to modify the plugin’s plural rules, you have to do it in the ‘manage_set_and_see_localization.gd’ script by modifying the ‘_apply_language_rule’ method.
-
In the ‘?plural’ column, you only need to write something in the cell next to the REFERENCE_KEY. It’s best if the ‘?plural’ parameter is always the same in all CSV documents. It can be a single character like “.”, or any letter. This makes it easier to use the ‘tr_n()’ function and others. For example:
| key |
?plural |
en |
pl |
| inventory.currency |
. |
Coin |
Moneta |
|
|
Coins |
Monety |
|
|
|
Monet |
| inventory.arrow |
. |
Arrow |
Strzała |
|
|
Arrows |
Strzały |
|
|
|
Strzał |
#tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"")
tr_n("ANY_REFERENCE_KEY", ".", 2)
(Source: The table was copied from one of the comments, on the Localization using spreedsheets from the Godot documentation.)
NOTE
This step isn’t required for the plugin, but it’s good to know if you’re not familiar with this type of table.
-
Tables ‘?context’:
-
Combined ‘?plural’ / ‘?context’ tables:
I think this completes the CSV section. I hope it helps you with your projects.
If you have any questions or suggestions, please feel free to ask them here.
Regards.