Skip to content

gui: Translate theme names in settings - #8006

Merged
calmh merged 5 commits into
syncthing:mainfrom
acolomb:translate-gui-names
Oct 20, 2021
Merged

calmh merged 5 commits into
syncthing:mainfrom
acolomb:translate-gui-names

Conversation

@acolomb

@acolomb acolomb commented Oct 17, 2021 •

Copy link
Copy Markdown
Member

Purpose

Supersedes #7441 with a different approach. Add each subdirectory of the guiDir as a translation candidate string.
The key is prefixed with "theme-name-" and the default English translation corresponds to the directory name turned to title case. Disable the automatic name mangling in the GUI JS code in favor of just looking up the translation.

Testing

The second commit shows the effect of running go run build.go translate and manually adds a German translation for testing. It should be reverted before merging! Just let the automatic translation scripts handle it instead.

Verified to show translated names in German language setting and no visible change in the English setting. Other, yet untranslated languages show the capitalized theme directory name.

To-Do

  • Check what happens for other languages in Transifex where there is no translation yet. Will it copy the key or just apply the English translation as a fallback?
  • This will not work correctly for themes supplied in the STGUIASSETS directory. Maybe a check could be added if the translated string is still prefixed with theme-name- and fall back to the old capitalization code in JS?

Add each subdirectory of the guiDir as a translation candidate string.
The key is prefixed with "theme-name-" and the default English
translation corresponds to the directory name turned to title case.
Disable the automatic name mangling in the GUI JS code in favor of
just looking up the translation.
Import the outcome of "go run build.go translate" and manually copy it
to the German translation file for testing.

This commit should be reverted before merging!  Just let the automatic
translation scripts handle it instead.
Comment thread script/translate.go Resolved
When the translated string does not exists, we should not show the
"theme-name-*" key, but at least a prettified folder name.  Fall back
to converting the theme directory name to Title Case when this is
detected.
@acolomb

acolomb commented Oct 18, 2021

Copy link
Copy Markdown
Member Author

I added a fallback logic just in case the translation returns the key as-is with the theme-name- prefix. That should solve the two open points above. Not quite sure how user-supplied themes in STGUIASSETS should be translated though.

@acolomb

acolomb commented Oct 18, 2021

Copy link
Copy Markdown
Member Author

Seems one can also extend the translations quite easily, just copy the lang-*.json file to $STGUIASSETS/default/assets/lang/ and edit it there to add the new theme name. So I guess that's not a blocker.

@AudriusButkevicius AudriusButkevicius left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@calmh
calmh merged commit 3e3954e into syncthing:main Oct 20, 2021
@calmh

calmh commented Oct 20, 2021

Copy link
Copy Markdown
Member

(I did see the note about reverting the manual translation changes, but chose not to worry about it as it'll get overwritten in the end.)

@acolomb

acolomb commented Oct 20, 2021

Copy link
Copy Markdown
Member Author

That's fine, thanks.

@acolomb
acolomb deleted the translate-gui-names branch October 20, 2021 19:26
@calmh calmh added this to the v1.18.4 milestone Oct 27, 2021
calmh added a commit to calmh/syncthing that referenced this pull request Nov 22, 2021
* main: (32 commits)
  cmd/syncthing: Implement generate as a subcommand with optional API credential setting (fixes syncthing#8021) (syncthing#8043)
  lib/model: Correct "reverting folder" log entry
  lib/model: Correct handling of fakefs cache
  gui, lib: Fix tracking deleted locally-changed on encrypted (fixes syncthing#7715) (syncthing#7726)
  lib/config: Move the bcrypt password hashing to GUIConfiguration (syncthing#8028)
  lib/syncthing: Clean up / refactor LoadOrGenerateCertificate() utility function. (syncthing#8025)
  lib/api: http.Request.BasicAuth instead of custom code (syncthing#8039)
  Normalize CLI options to always use two dashes. (syncthing#8037)
  gui: Display identicons for discovered device IDs. (syncthing#8022)
  cmd/syncthing/cli: indexDumpSize doesn't need a heap (syncthing#8024)
  lib/model: Optimize jobQueue performance and memory use (syncthing#8023)
  lib/model: Limit the number of default hashers on Android (ref syncthing#2220)
  lib/model: Set mod. time after writing trailer in shortcut (ref syncthing#7992)
  lib/protocol: Simplify codeToError, errorToCode
  lib/protocol: Eliminate nativeModel on Unix
  gui: Add direct link to Ignore Patterns from folder panel (fixes syncthing#4293) (syncthing#7993)
  gui: Translate theme names in settings (syncthing#8006)
  lib/model: Pull when a new connection is established (fixes syncthing#8012) (syncthing#8013)
  gui, man, authors: Update docs, translations, and contributors
  gui, man, authors: Update docs, translations, and contributors
  ...
calmh added a commit to calmh/syncthing that referenced this pull request Nov 22, 2021
* main: (32 commits)
  cmd/syncthing: Implement generate as a subcommand with optional API credential setting (fixes syncthing#8021) (syncthing#8043)
  lib/model: Correct "reverting folder" log entry
  lib/model: Correct handling of fakefs cache
  gui, lib: Fix tracking deleted locally-changed on encrypted (fixes syncthing#7715) (syncthing#7726)
  lib/config: Move the bcrypt password hashing to GUIConfiguration (syncthing#8028)
  lib/syncthing: Clean up / refactor LoadOrGenerateCertificate() utility function. (syncthing#8025)
  lib/api: http.Request.BasicAuth instead of custom code (syncthing#8039)
  Normalize CLI options to always use two dashes. (syncthing#8037)
  gui: Display identicons for discovered device IDs. (syncthing#8022)
  cmd/syncthing/cli: indexDumpSize doesn't need a heap (syncthing#8024)
  lib/model: Optimize jobQueue performance and memory use (syncthing#8023)
  lib/model: Limit the number of default hashers on Android (ref syncthing#2220)
  lib/model: Set mod. time after writing trailer in shortcut (ref syncthing#7992)
  lib/protocol: Simplify codeToError, errorToCode
  lib/protocol: Eliminate nativeModel on Unix
  gui: Add direct link to Ignore Patterns from folder panel (fixes syncthing#4293) (syncthing#7993)
  gui: Translate theme names in settings (syncthing#8006)
  lib/model: Pull when a new connection is established (fixes syncthing#8012) (syncthing#8013)
  gui, man, authors: Update docs, translations, and contributors
  gui, man, authors: Update docs, translations, and contributors
  ...
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Mar 10, 2023
@syncthing syncthing locked and limited conversation to collaborators Mar 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants