Research solutions for localization #393
Labels
No labels
_CRITICAL_
API
app
backEnd
Blocked, waiting for further changes
bug
cleanup
close
design
duplicate
enhancement
feature request
frontEnd
help wanted
invalid
low priority
needs input
needs review
project documentation
question
research
reviewed
script
security
SQL
style
testing
topLevel
wontfix
No milestone
No project
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Andras/BoundlessFlowCampus2K#393
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Option:1
React's Context API
Using Reacts' Context API (createContext, useContext) a language can be set to English/Swedish and stored globally in
<App>.Child components and views can then access the current language and use a translation file in that view/component to get the correct text
positives
Negatives
Overall
If we just use it for choosing between translation outputs and do not intend to implement many languages, it is a good choice.
If a lot of formatting (numbers, dates) and interpolation (adding variables to strings) occurs, then more work is required.
Option:2
i18next/react-i18next
react-i18next is a library that builds on i18next and uses React’s Context API internally, similar to Option:1, with the difference that the functionality is pre-made for ease of use. In the Github repo we can see that it has the MIT license, a large pool of contributors, and an average of 11 million downloads per week, making it a well-tested and widely used library.
Positives
Negatives
Overall
It is well tested and widely used, and if many languages and advanced functionality are required, it is a good choice.
However, depending on usage, it might become too large for what is required.
Might add other options and keep adding to the once existing is later stages
The research is good overall, the trade-offs are well explained and the main decision point seem to be whether we expect translation to grow more complex over time. Since that will largely determine whether we should choose a lightweight context API solution or if a more complete library like react-i18next is better.
The comparison makes it clear that option 1 is better for simplicity and control while option 2 would reduce the maintenance risk in the future by handling common i18n concerns such as pluralization, interpolation, formatting, etc.
This might be something that should be brought before the customer such as issue: #402. Since in option2 we need to introduce external dependencies which could be a factor in the requirements.
b24krila referenced this issue2026-04-20 14:15:02 +00:00
The same answer as in #402, we should decide which one to use depending on an evaluation. It looks like React has built in localization and Henrik was a big fan since it doesn't add any dependencies. Us group leaders will decide this as soon as possible.
It seems to use that React has a sort of built-in localization tool (React's Context API) and since we already use React and want as few dependencies as possible we have decided to use it.
When we talked with Henrik we talked about word count for the page. Since it is relatively low and we can translate it ourselves we should use something like a built in system instead of introducing something that can break.
If this turns out to be still a pain to setup even with our low word count we could consider changing to something else.