Set & See, Localization Key

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.

    • The button has two properties: Mode and Target Text Node.

      • Mode: These are the classic ‘Set’ and ‘See’. When the button is pressed, it activates the corresponding window.

      • Target Text Node: This must be a node with the Text property, to which the effect of the selected mode is applied.

  • 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:

  • Other adjustments have been made and bugs fixed.

  • New features have been added to the ‘Set’ and ‘See’ windows:

    • In the ‘See’ window:

      • toggle BBCode format, font size, line separation, paragraph separation, and horizontal alignment.

  • 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

  • Compatibility with ‘?plural’, ‘?context’, and combined ‘?plural / ?context’ tables. Keys and values ​for these special tables can be viewed and set.

    What are the ‘?plural’, ‘?context’, and ‘?plural / ?context’ tables?

    If you’re not familiar with these tables, I recommend reading the Godot documentation. In summary:

    • The ‘?plural’ tables allow the use of different plurals, since depending on the language, more than one plural form can be used (2, 3, 4, and even 5).

      It’s important to note that not all values in the column are plural, as the first value is usually singular, and the rest are the different plural forms. Therefore, the value placed on the same line as the REFERENCE_KEY is the singular form, and the rest are the plural forms, from smallest to largest, going down the column. Of course, this depends on the language.

    • The ‘?context’ tables are used when a word can have an ambiguous meaning depending on the language, and the best way to differentiate it is by considering the context.
    • Tables with any of these properties will appear with a suffix next to the CSV name in the ‘Treekey’ field of the ‘Set’ window, indicating the special table type. Clicking on one of its reference keys displays one or two buttons, depending on its type:
      • Amount for [Plural] type tables. A SpinBox that allows you to modify the amount.
      • Context for [Context] type tables. An OptionButton that contains all the contexts associated with the reference key.
      • In the case of combined tables, both options appear.

  • 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’:

        • All ‘context’ groups must have the same REFERENCE_KEY (just as if the first column were a language, it would have to be the same word). e.g.:

          key ?context fr ru en ja zh
          LETTER Alphabet Lettre Буква Letter 字母 字母
          LETTER Message Courrier Письмо Letter 手紙 信件
          ANOTHER_KEY context_a example_fr_0 example_ru_0 example_en_0 example_ja_0 example_zh_0
          ANOTHER_KEY context_b example_fr_1 example_ru_1 example_en_1 example_ja_1 example_zh_1
          ANOTHER_KEY context_c example_fr_2 example_ru_2 example_en_2 example_ja_2 example_zh_2
      • Combined ‘?plural’ / ‘?context’ tables:

        • These are governed by the same rules as all the previous ones.

          key ?plural ?context en_GB es_ES de it pt
          ANOTHER_KEY . context_a example_en-0 example_es-0 example_de-0 example_it-0 example_pt-0
          example_en-1 example_es-1 example_de-1 example_it-1 example_pt-1
          ANOTHER_KEY . context_b example_en-0 example_es-0 example_de-0 example_it-0 example_pt-0
          example_en-1 example_es-1 example_de-1 example_it-1 example_pt-1
          ANOTHER_KEY . context_c example_en-0 example_es-0 example_de-0 example_it-0 example_pt-0
          example_en-1 example_es-1 example_de-1 example_it-1 example_pt-1
          PLUS_KEY . context_a example_en-0 example_es-0 example_de-0 example_it-0 example_pt-0
          example_en-1 example_es-1 example_de-1 example_it-1 example_pt-1
          PLUS_KEY . context_b example_en-0 example_es-0 example_de-0 example_it-0 example_pt-0
          example_en-1 example_es-1 example_de-1 example_it-1 example_pt-1

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.