Closed coreyshuman closed 1 year ago
Notifications Page
Editor Home Page
Search bar
Changelog
Copyright Line
Change my Email modal
Verify Email Change Page
And I found a few other cases were notifications were not translated. We currently hand notifications in a mixture of places including pages, hooks, and services. It's a bit confusing and hard to tell who should be responsible for what. I'll add a note to take a look at this for possible refactor.
Updated commit will come in later tonight.
Changes
Constants
file andyup
schemas to support translationPurpose
This PR adds comprehensive i18n coverage for English and Spanish (Latin America). All static content on the front-end application is included.
User input and server-driven content is NOT translated. Date and time localization is NOT included.
Approach
This PR builds on the initial translation efforts which had already began on this project. We use the react-i18next package to power our translation functionality. I split translations into two files:
common.json
andtranslation.json
in an attempt to separate reusable common entries from page-specific translations.Learning
The
useTranslation
hook andt()
functions are the primary approach for implementing translation, as recommended by thereact-18next
documentation. This functional approach is nice because it can also be used for programmatic translations, such as passing a localized string to a notification toast. It also has the advantage of updating in real-time. The limitation is that this approach cannot do interpolation or complex components.https://react.i18next.com/latest/usetranslation-hook
Example:
The
<Trans>
component is used when more complex translations are needed, such as strings with username or email populated in them. This approach will not automatically update in real-time, so component re-render needs to be handled manually.https://react.i18next.com/latest/trans-component
Example:
This approach is also useful when you need to support pluralization, which is enabled when supplying the
count
prop.https://www.i18next.com/translation-function/plurals
In that case, the pluralized translation strings for the above code example would look like this:
Pre-Testing TODOs
None, just pull down the branch as normal.
Testing
Closes Proofhub task: https://bitwiseindustries.proofhub.com/bapplite/#app/todos/project-7536720926/list-263379767795/task-303770912950