-
Notifications
You must be signed in to change notification settings - Fork 787
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
refactor: translate() to t() #777
Conversation
src/utils/localization-helper.js
Outdated
if (typeof interpolation[match[2]] === 'undefined') { | ||
ongoing += this.config.missingPlaceholder; | ||
} else if (typeof interpolation[match[2]] === 'object') { | ||
const value = interpolation[match[2]]; |
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.
You can also add a local variable to save typeof value
. And how about to replace the while loop with translation.replace(componentPlaceholdersReg, (match) => { /* blabla */ })
?
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.
Done for the local typeof value
const.
I didn't know that replace() also accepted a callback as a second parameter, named parameters greatly improve code readability, thank you!
@chinesedfan could you pull this PR and check if everything is okay for zh? 🙏 |
Beautiful :) If you would like me to pull it down and review locally as well, let me know - I can do that shortly if need be 🙏 |
@machour I noticed a bug due to |
@chinesedfan Thank you for spotting this! Fixed by setting I18n.defaultSeparator = 'GITPOINT-DISABLED'; |
@housseindjirdeh yes please! Absolutely nothing should change on the UI side with this PR. This kind of renders react-native-i18n useless (see #783) and will make switching to lingui-js or other more translator friendly libraries painless in the future :) I'll add some documentation for translation handling once this is merged. |
Perused through the app, and couldn't find any translation files missing/broken 👍 |
Description
Wrote a babel-traverse script that took care of migrating all calls from
translate()
tot()
swapping keys with strings everywhere.Then did some polishing for the relativeTimeFromNow() function & fixed a few things in t().
Also removed untranslated english sentences from translation files.
Should be good to go!
Next thing will be to go over some of the old concatenations we're currently doing and turn those into plain sentences (like I did for the events screen)