@deriv-com/translations 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,14 +36,15 @@ To get started, one would need few things to setup first which are:
|
|
|
36
36
|
- Create a new bucket in the R2 account.
|
|
37
37
|
- Create a new access key in the R2 account.
|
|
38
38
|
3. Add the following secrets to your repository:
|
|
39
|
-
- `CROWDIN_PROJECT_ID`: Open your crowdin project and navigate to `Tools` tab, you will be able to get the Project ID, store that in your github secrets
|
|
40
|
-
- `CROWDIN_PERSONAL_TOKEN`: This can be obtained by logging in to your crowdin account and clicking on your profile icon and goto `Settings > API` and create a new personal access token, store that in your github secrets
|
|
41
|
-
- `R2_ACCOUNT_ID`: R2 account ID from the Cloudflare R2 dashboard
|
|
42
|
-
- `R2_ACCESS_KEY_ID`: R2 access key ID from the Cloudflare R2 dashboard
|
|
43
|
-
- `R2_SECRET_ACCESS_KEY`: R2 secret access key from the Cloudflare R2 dashboard
|
|
44
|
-
- `R2_BUCKET_NAME`: R2 bucket name from the Cloudflare R2 dashboard
|
|
39
|
+
- `CROWDIN_PROJECT_ID`: Open your crowdin project and navigate to `Tools` tab, you will be able to get the Project ID, store that in your github secrets.
|
|
40
|
+
- `CROWDIN_PERSONAL_TOKEN`: This can be obtained by logging in to your crowdin account and clicking on your profile icon and goto `Settings > API` and create a new personal access token, store that in your github secrets.
|
|
41
|
+
- `R2_ACCOUNT_ID`: R2 account ID from the Cloudflare R2 dashboard.
|
|
42
|
+
- `R2_ACCESS_KEY_ID`: R2 access key ID from the Cloudflare R2 dashboard.
|
|
43
|
+
- `R2_SECRET_ACCESS_KEY`: R2 secret access key from the Cloudflare R2 dashboard.
|
|
44
|
+
- `R2_BUCKET_NAME`: R2 bucket name from the Cloudflare R2 dashboard.
|
|
45
45
|
4. Add the following environment variable in your repository:
|
|
46
|
-
- `PROJECT_NAME`: Add project name in your environment variable which will be used for Cloudflare R2 folder name for translations
|
|
46
|
+
- `PROJECT_NAME`: Add project name in your environment variable which will be used for Cloudflare R2 folder name for translations.
|
|
47
|
+
- `CROWDIN_BRANCH_NAME`: Add the branch name for your crowdin project to separate the translations based on environment, this needs to be put into the environment variable instead of secret because the consumer of the package needs it while defining the `cdnUrl` to access the translations.
|
|
47
48
|
5. Setup the github action to sync the translations to the CDN, refer to the [Syncing translations](#syncing-translations) section for more details.
|
|
48
49
|
|
|
49
50
|
Install the package by running:
|
|
@@ -54,7 +55,7 @@ npm install @deriv-com/translations
|
|
|
54
55
|
|
|
55
56
|
### Setup
|
|
56
57
|
|
|
57
|
-
- initialize translations in main component by importing and calling `initializeI18n` outside of the component function
|
|
58
|
+
- initialize translations in main component by importing and calling `initializeI18n` outside of the component function.
|
|
58
59
|
- pass the return value to the `TranslationProvider` component from `@deriv-com/translations`.
|
|
59
60
|
- pass default language to the `TranslationProvider` component.
|
|
60
61
|
|
|
@@ -86,7 +87,7 @@ import initializeI18n from "@deriv-com/translations";
|
|
|
86
87
|
initializeI18n({ cdnUrl: "https://cdn.example.com" });
|
|
87
88
|
```
|
|
88
89
|
|
|
89
|
-
- For strings use either `localize(...)` or `<Localize
|
|
90
|
+
- For strings use either `localize(...)` or `<Localize />`.
|
|
90
91
|
|
|
91
92
|
### `Localize` component example:
|
|
92
93
|
|
|
@@ -137,22 +138,22 @@ There is a github action that syncs the translations from Crowdin to the CDN.
|
|
|
137
138
|
|
|
138
139
|
The action takes following inputs:
|
|
139
140
|
|
|
140
|
-
- `PROJECT_SOURCE_DIRECTORY`: Source directory of your project by default it is `src
|
|
141
|
-
- `CROWDIN_BASE_PATH`: Base path of the translations in the Crowdin project by default it is
|
|
142
|
-
- `CROWDIN_BASE_URL`: Base URL of the CDN where the translations are stored, default is `https://api.crowdin.com
|
|
143
|
-
- `CROWDIN_BRANCH_NAME`: Running on production, test or staging etc
|
|
144
|
-
- `CROWDIN_PROJECT_ID`: Crowdin project ID which can be found in the crowdin project settings
|
|
145
|
-
- `CROWDIN_PERSONAL_TOKEN`: Crowdin personal token which can be found in the crowdin account settings
|
|
146
|
-
- `R2_ACCOUNT_ID`: R2 account ID from the Cloudflare R2 dashboard
|
|
147
|
-
- `R2_ACCESS_KEY_ID`: R2 access key ID from the Cloudflare R2 dashboard
|
|
148
|
-
- `R2_SECRET_ACCESS_KEY`: R2 secret access key from the Cloudflare R2 dashboard
|
|
149
|
-
- `R2_BUCKET_NAME`: R2 bucket name from the Cloudflare R2 dashboard
|
|
141
|
+
- `PROJECT_SOURCE_DIRECTORY`: Source directory of your project by default it is `src`.
|
|
142
|
+
- `CROWDIN_BASE_PATH`: Base path of the translations in the Crowdin project by default it is `.`.
|
|
143
|
+
- `CROWDIN_BASE_URL`: Base URL of the CDN where the translations are stored, default is `https://api.crowdin.com`.
|
|
144
|
+
- `CROWDIN_BRANCH_NAME`: Running on production, test or staging etc.
|
|
145
|
+
- `CROWDIN_PROJECT_ID`: Crowdin project ID which can be found in the crowdin project settings.
|
|
146
|
+
- `CROWDIN_PERSONAL_TOKEN`: Crowdin personal token which can be found in the crowdin account settings.
|
|
147
|
+
- `R2_ACCOUNT_ID`: R2 account ID from the Cloudflare R2 dashboard.
|
|
148
|
+
- `R2_ACCESS_KEY_ID`: R2 access key ID from the Cloudflare R2 dashboard.
|
|
149
|
+
- `R2_SECRET_ACCESS_KEY`: R2 secret access key from the Cloudflare R2 dashboard.
|
|
150
|
+
- `R2_BUCKET_NAME`: R2 bucket name from the Cloudflare R2 dashboard.
|
|
150
151
|
|
|
151
|
-
Refer to the action file [here](https://github.com/deriv-com/translations/blob/main/.github/actions/extract_and_sync_translations/action.yml)
|
|
152
|
+
Refer to the action file [here](https://github.com/deriv-com/translations/blob/main/.github/actions/extract_and_sync_translations/action.yml).
|
|
152
153
|
|
|
153
154
|
### Example usage of the action in the workflow file:
|
|
154
155
|
|
|
155
|
-
Copy and paste the following workflow code in your repository in this path`.github/workflows/sync_translations.yml
|
|
156
|
+
Copy and paste the following workflow code in your repository in this path`.github/workflows/sync_translations.yml`.
|
|
156
157
|
|
|
157
158
|
```yaml
|
|
158
159
|
name: Sync translations
|
|
@@ -161,19 +162,18 @@ on:
|
|
|
161
162
|
push:
|
|
162
163
|
branches:
|
|
163
164
|
- 'main'
|
|
165
|
+
schedule:
|
|
166
|
+
- cron: '0 */12 * * *'
|
|
164
167
|
|
|
165
168
|
jobs:
|
|
166
169
|
sync_translations:
|
|
167
170
|
runs-on: ubuntu-latest
|
|
168
171
|
steps:
|
|
169
|
-
- name: Checkout to main branch
|
|
170
|
-
uses: actions/checkout@v3
|
|
171
|
-
|
|
172
172
|
- name: Sync translations
|
|
173
173
|
uses: deriv-com/translations/.github/actions/extract_and_sync_translations@main
|
|
174
174
|
with:
|
|
175
175
|
PROJECT_NAME: ${{ env.PROJECT_NAME }}
|
|
176
|
-
CROWDIN_BRANCH_NAME: ${{
|
|
176
|
+
CROWDIN_BRANCH_NAME: ${{ env.CROWDIN_BRANCH_NAME }}
|
|
177
177
|
CROWDIN_BASE_URL: ${{ env.CROWDIN_BASE_URL }}
|
|
178
178
|
CROWDIN_BASE_PATH: ${{ env.CROWDIN_BASE_PATH }}
|
|
179
179
|
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
package/package.json
CHANGED