Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added English texts in en.json #2098

Draft
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

Zhongyi-Lu
Copy link
Contributor

Related to #2074

Could anybody check if there are any typos?

@Touch-Night
Copy link
Contributor

They're not original text and does not fit all the text shown in the webpage.
Better if you extract all the elements with <data-i18n=""> tag and put them all in en.json.

@Zhongyi-Lu
Copy link
Contributor Author

@Touch-Night Good idea!

@Touch-Night
Copy link
Contributor

Touch-Night commented Apr 17, 2024

Note: not all <data-i18n> tag takes effects and there are some values like <data-i18n="[title]xxxx">, then in json file the key should be xxxx, not [title]xxxx.
And incorrect order of keys in json file may break ST. I discovered that when I tried to extract all the <data-i18n>

@Cohee1207
Copy link
Member

"en" is intentionally left empty. Having to update texts both in HTML and JSON is going to make development more cumbersome and directly impact a delivery of new features.

@Cohee1207
Copy link
Member

Cohee1207 commented Apr 17, 2024

Instead of making it affect the localization files - make it able to find missing key placeholders to already existing localization files.

@Touch-Night
Copy link
Contributor

But translators can be more cumbersome if there's no a full list of key: "original text" because we have to go through every page to find out which one are not translated and what's its key. Can't you make ST read original text from en.json, or just give us a need_to_be_translated.json file only for reference so we can translate ST 100%?

@Zhongyi-Lu Zhongyi-Lu marked this pull request as draft April 17, 2024 21:10
@Zhongyi-Lu
Copy link
Contributor Author

And incorrect order of keys in json file may break ST

@Touch-Night Do you mean the order in the translation JSON file matters? It's a bit strange.

@Zhongyi-Lu
Copy link
Contributor Author

Zhongyi-Lu commented Apr 18, 2024

I find there are 3 cases for the data-i18n:

  1. values are in the block
    Example:<li><button id="character_context_menu_favorite" data-i18n="Favorite">Favorite</button></li>
  2. values are in the attributes
    Example: <i data-newbie-hidden title="Import preset" id="import_oai_preset" class="menu_button fa-solid fa-file-import" data-i18n="[title]Import preset"></i>
  3. values in the JS files
    Example:
const footerHtml = `
                <div class="${this.configuration.prefix}prompt_manager_footer">
                    <select id="${this.configuration.prefix}prompt_manager_footer_append_prompt" class="text_pole" name="append-prompt">
                        ${promptsHtml}
                    </select>
                    <a class="menu_button fa-chain fa-solid" title="Insert prompt" data-i18n="[title]Insert prompt"></a>
                    <a class="caution menu_button fa-x fa-solid" title="Delete prompt" data-i18n="[title]Delete prompt"></a>
                    <a class="menu_button fa-file-import fa-solid" id="prompt-manager-import" title="Import a prompt list" data-i18n="[title]Import a prompt list"></a>
                    <a class="menu_button fa-file-export fa-solid" id="prompt-manager-export" title="Export this prompt list" data-i18n="[title]Export this prompt list"></a>
                    <a class="menu_button fa-undo fa-solid" id="prompt-manager-reset-character" title="Reset current character" data-i18n="[title]Reset current character"></a>
                    <a class="menu_button fa-plus-square fa-solid" title="New prompt" data-i18n="[title]New prompt"></a>
                </div>
            `;

For the first and second cases, it is easy to extract English texts by parsing HTML using BeautifulSoup in Python.
The third case is harder. I try to extract them using Regex but I didn't manage to do it.

Fortunately, we only have about 20 key-value pairs in the 3rd case and it is okay to manually copy them to the JSON file.

I would like to mention my current progress here. If we think adding en.json is necessary, I can keep moving forward. Otherwise, I will pause my work and wait for the consensus. Thank you!

@Cohee1207
Copy link
Member

Cohee1207 commented Apr 18, 2024

en.json was present in the past but was emptied as it was annoying to work with - you have to go and change the text if you change it in the HTML, it is not convenient for developers and contributors who are working on new features. A script that will fill out the localization JSON files with the string keys to translate will be nice. But I'm actually thinking about an alternative to JSON that supports files - .js files that declare a key-value object in its exports and provide comments with the original text.

export const i18n = {
    // original value
   "key text": "翻译",
   // ...etc
};

This would require a slight rework of the i18n loader, however.

@PasserDreamer
Copy link
Contributor

I think it would be better to create a template.js that won't be used directly. This way, managing translations in the future will be easier and it won't interfere with the English interface.

@Cohee1207
Copy link
Member

I think it would be better to create a template.js that won't be used directly.

This still raises the question of who would be responsible for maintaining this template in an up-to-date state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants