Open
Conversation
Make them all the same and import from locales/index.js to ensure the translations are always added.
| errorText: i18n.t( | ||
| 'There was a problem loading items. Try again or contact your system administrator.' | ||
| ), | ||
| noDataText: i18n.t('No items found. Create a new to get started.'), |
Collaborator
There was a problem hiding this comment.
Kind of a weird sentence (I know this was already present): "Create a new to get started."
jenniferarnesen
previously approved these changes
Nov 1, 2024
Contributor
HendrikThePendric
left a comment
There was a problem hiding this comment.
I wonder if there is perhaps a better solution to this problem. The current solution has 2 downsides as I see it:
- importing from the file
locales/index.jsis less ergonomic than importing from the package@dhis2/d2-i18n - The file
locales/index.jsactually does do quite a lot. If we import this file in a lot of places the calls to.addResources()will be happening often. I don't know if this is a problem, but doesn't seem desirable
I'm thinking the following:
- To ensure we always "load the translations" for consumers of the lib, we can import the
locales/index.jsfile from our own index file, since consuming apps should be importing from there exclusively (if this is not true, I think the current implementation in this PR is probably the best solution) - To avoid running the code in
locales/index.jsmultiple times, we probably would have to do a dynamic import, i.e. something like this:- Import the i18n singleton from
@dhis2/d2-i18n - check if our translations have been added (not sure how, but I think it may be possible)
- If not dynamically import the
locales/index.jsfile
- Import the i18n singleton from
- We could consider checking how this is done in @dhis2/ui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Key features
i18neverywherei18n.tgets executed for all translatable stringsDescription
We had 2 ways of import
i18nin the library.I don't think we had problems due to this, but for consistency sake and to avoid possible issues, it's good to import everywhere from the same place.
Importing from
locales/index.jsensures that the library translations are added and are available in the consumer apps.Some strings did not show translated in consumer apps, the reason is likely marking
i18n.tstrings in static constants or objects, in that case thei18n.tfunction is not called at runtime.