-
Notifications
You must be signed in to change notification settings - Fork 878
Fix: Correct service name translations in dashboard widget #8935
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
base: master
Are you sure you want to change the base?
Conversation
|
If there's an issue with the context, we should fix that at the caller, this will be quite confusing and prone to future mistakes. (assuming we don't want to remove the *** EDIT *** The proper fix will likely be a bit more complicated to apply, ideally |
|
If we agree pluginctl doesn’t care about user language we can actually say this is the correct fix, although in that case we should try to wrap all the variables that are translated (not sure if there are more without looking at the code). Cheers, |
|
To understand this: In this pull request, the services are translated when they are called from the API (context is present). An alternative would be to translate them directly in the widget. The translations for this are defined in the file For example: But it's weird with the spaces and I don't know if it works. You could also change the descriptions of the services in the With this approach, the translations would be defined, the .po files would be generated with them and gettext() could be removed in core.inc. What do you think? P.S. This is my first deeper dive into the OPNsense internals, so please feel free to point out anything I might have misunderstood or could improve. |
|
I double checked and the description is the only thing that is translated for services. Since all files already wrap their description in gettext() I believe this change is correct to move the pluginctl feed from the default language to the user's logged in language. |
|
I agree the most logical place to handle the translations would indeed be the controller layer as we have all relevant context available there, in which case this would be correct but leaves the issue of the I'm struggling a bit with the pros and cons of moving the text to translate into separate files here. To some degree it feels simpler/cleaner to just stuff the translations in the file and not use the outcome. Which would lead to something like this: My main concern is trowing different than expected output when calling |
|
OK, how do we want to do it? Like in your example? Then I would do that. |
|
@tobiasdegen we're a bit busy with the upcoming release and need time to discuss this internally. In the meantime we'll keep the PR open. |
|
OK, all right. |
|
Discussed options a bit today: https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html C and Perl support |
|
I did a short partial test with 039382f but it looks like work that's better not spent since it requires more targeted changes, ideally an upstream PHP and gettext support or at least more sed glue in lang.git in order to extract those things. And then we still need to micro-manage every translatable string that should be treated as a "delayed" translation. |
Hi,
I've fixed the translations of the service names shown in the "Services" widget on the dashboard.
Originally, the translations were defined in
src/etc/inc/core.inc, but they were not applied because the language system is not initialized at that stage — there's no user context available yet.Since the widget retrieves the translated strings directly via the API, the translations are now properly applied in that context.
However, I’ve left the
gettext()calls incore.incso that the strings are still included in the.pofiles and can be translated through the usual localization process.Best regards,
Tobias