@deriv-com/translations 1.1.4 → 1.2.1
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 +20 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,22 @@ base_url is the cdnUrl passed to the `initializeI18n` function, and lang is the
|
|
|
30
30
|
|
|
31
31
|
## Getting Started
|
|
32
32
|
|
|
33
|
+
To get started, one would need few things to setup first which are:
|
|
34
|
+
1. A Crowdin project which will be used to manage translations for your project.
|
|
35
|
+
2. A Cloudflare R2 account to store the translations.
|
|
36
|
+
- Create a new bucket in the R2 account.
|
|
37
|
+
- Create a new access key in the R2 account.
|
|
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
|
|
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
|
|
47
|
+
5. Setup the github action to sync the translations to the CDN, refer to the [Syncing translations](#syncing-translations) section for more details.
|
|
48
|
+
|
|
33
49
|
Install the package by running:
|
|
34
50
|
|
|
35
51
|
```bash
|
|
@@ -102,7 +118,7 @@ The useTranslations hook is a custom hook that adds some more returned values on
|
|
|
102
118
|
Example usage:
|
|
103
119
|
|
|
104
120
|
```javascript
|
|
105
|
-
import { useTranslations } from "@deriv-com/
|
|
121
|
+
import { useTranslations } from "@deriv-com/translations";
|
|
106
122
|
|
|
107
123
|
const MyComponent = () => {
|
|
108
124
|
const { localize, switchLanguage, currentLang } = useTranslations();
|
|
@@ -136,6 +152,8 @@ Refer to the action file [here](https://github.com/deriv-com/translations/blob/m
|
|
|
136
152
|
|
|
137
153
|
### Example usage of the action in the workflow file:
|
|
138
154
|
|
|
155
|
+
Copy and paste the following workflow code in your repository in this path`.github/workflows/sync_translations.yml`
|
|
156
|
+
|
|
139
157
|
```yaml
|
|
140
158
|
name: Sync translations
|
|
141
159
|
|
|
@@ -154,6 +172,7 @@ jobs:
|
|
|
154
172
|
- name: Sync translations
|
|
155
173
|
uses: deriv-com/translations/.github/actions/extract_and_sync_translations@main
|
|
156
174
|
with:
|
|
175
|
+
PROJECT_NAME: ${{ env.PROJECT_NAME }}
|
|
157
176
|
CROWDIN_BRANCH_NAME: ${{ secrets.CROWDIN_BRANCH_NAME }}
|
|
158
177
|
CROWDIN_BASE_URL: ${{ env.CROWDIN_BASE_URL }}
|
|
159
178
|
CROWDIN_BASE_PATH: ${{ env.CROWDIN_BASE_PATH }}
|
package/package.json
CHANGED