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

Translate the storage texts #726

Merged
merged 2 commits into from
Aug 30, 2023
Merged

Translate the storage texts #726

merged 2 commits into from
Aug 30, 2023

Conversation

lslezak
Copy link
Contributor

@lslezak lslezak commented Aug 30, 2023

  • Just marking more texts for translation, this time in the storage area
  • Additionally I edited the InstallButton.jsx file to use square brackets - it looks better and it is more compatible with the Markdown format (it is cheap to do it now, we do not have translations yet)

// either use toLocaleString()
// (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString)
// or use the "globalize" JS library which can also parse the localized string back
// (https://github.com/globalizejs/globalize#number-module)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

// constants need to be marked for translation with N_() and translated with _() later
const SIZE_OPTION_LABELS = Object.freeze({
// TRANSLATORS: radio button label, fully automatically computed partition size, no user input
auto: N_("Auto"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: why N_ instead of _ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That constant is evaluated too early, at that point the cockpit.language is not initialized yet and the text would not be translated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, thanks for the explanation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi guys!

Yesterday I found this looking more information about N_ when reviewing ancorgs's PR. I know that N_ is used to mark for translation, but I do not understand why it is needed either, here and in the @ancorgs's PR linked above.

Also, I wonder if, in case of really needed, this will change with the new architecture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The N_ macro/function used for translating constants, it does not depend on the architecture or programming language (you can use use it even in C or C++ code).

The problem is that

Object.freeze({
  auto: _("Auto"),
   ...

would translate the value using the language configured at the initialization, it would not retranslate the text after changing the language later at runtime.

https://yastgithubio.readthedocs.io/en/latest/localization/#translating-constants

@coveralls
Copy link

Coverage Status

coverage: 74.458% (+0.003%) from 74.455% when pulling 13b3041 on storage_translations into 1ca0f35 on master.

@lslezak lslezak merged commit 2e2e80a into master Aug 30, 2023
8 of 9 checks passed
@lslezak lslezak deleted the storage_translations branch August 30, 2023 12:21
@imobachgs imobachgs mentioned this pull request Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants