refactor: translate() to t() #777
Conversation
| if (typeof interpolation[match[2]] === 'undefined') { | ||
| ongoing += this.config.missingPlaceholder; | ||
| } else if (typeof interpolation[match[2]] === 'object') { | ||
| const value = interpolation[match[2]]; |
chinesedfan
Apr 22, 2018
•
Member
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 */ })?
machour
Apr 22, 2018
Author
Member
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 |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.


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)