-
Notifications
You must be signed in to change notification settings - Fork 43
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
Conversation
// 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) |
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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 _
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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)