Skip to content
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

UI: Add documentation on app localization script #181

Open
samundra opened this issue Mar 10, 2020 · 0 comments
Open

UI: Add documentation on app localization script #181

samundra opened this issue Mar 10, 2020 · 0 comments
Assignees
Labels
docs Improvements or additions to documentation ui Client side / ui changes
Milestone

Comments

@samundra
Copy link
Owner

samundra commented Mar 10, 2020

Current, application supports localization. All localization texts are updated with google spreadsheet. Link to google spreadsheet is https://docs.google.com/spreadsheets/d/1uwAk1xYNKc6S15ytl5OnPYCUKXxF8af4Cd6nFHgQCaM/edit#gid=1602672055

Whenever, we need to add/remove localization in app. This google spreadsheet has to be updated first. After google spreadsheet is updated, we have to run command yarn run fetch-language from project root directory.

OUTPUT OF yarn run fetch-language

~/personal/www/whoowesme/frontend (feature/issue-177 ✘)✹✭ ᐅ npm run fetch-language

> [email protected] fetch-language /Users/samundra/personal/www/whoowesme/frontend
> node scripts/load-language.js && eslint --fix src/i18n/languages/*.ts && prettier --write src/i18n/languages/*.ts

Read credentials.json
Read token from file token.json
Finished fetching spreadsheet
Finished fetching worksheet: Dashboard
Finished fetching worksheet: Menu
Finished fetching worksheet: ProfileMenu
Finished fetching worksheet: Common
Finished fetching worksheet: Error
Finished writing file /Users/samundra/personal/www/whoowesme/frontend/src/i18n/languages/ne.ts
Finished writing file /Users/samundra/personal/www/whoowesme/frontend/src/i18n/languages/en.ts
Finished writing file /Users/samundra/personal/www/whoowesme/frontend/src/i18n/languages/keys.ts
src/i18n/languages/en.ts 230ms
src/i18n/languages/keys.ts 21ms
src/i18n/languages/ne.ts 17ms

This will fetch latest changes from google spreadsheet and automatically updates app localization keys.

Then we can reference these updated keys in application as follows.

Import these files at top.

import { translate } from 'i18n'
import TKeys from 'i18n/translationKey

Then refer to keys as listed in google spreadsheet.

<span>{translate(TKeys.Menu.summary)}</span>

Here Menu is Google Sheet name and summary is key inside that sheet.

See screenshot below:

Screen Shot 2020-03-11 at 02 09 43

@samundra samundra added the docs Improvements or additions to documentation label Mar 10, 2020
@samundra samundra added this to the v1.0.0 milestone Mar 10, 2020
@samundra samundra self-assigned this Mar 10, 2020
@samundra samundra changed the title Add documentation on app localization script UI: Add documentation on app localization script Mar 19, 2021
@samundra samundra added the ui Client side / ui changes label Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation ui Client side / ui changes
Projects
None yet
Development

No branches or pull requests

1 participant