Skip to content

Commit f76ca33

Browse files
committed
add same local handling
1 parent 0fb9899 commit f76ca33

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

.github/workflows/publish.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: Publish
22

33
on:
4-
push:
5-
branches: [main]
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
68

79
jobs:
810
publish:
@@ -28,14 +30,14 @@ jobs:
2830
${{ runner.os }}-node-
2931
3032
- name: Install dependencies
31-
run: npm ci
33+
run: npm ci --legacy-peer-deps
3234

3335
- name: Build package
3436
run: npm run build
3537
env:
3638
BASE_URL: ${{ secrets.BASE_URL }}
3739

38-
# - name: Publish to NPM
39-
# run: npm publish
40-
# env:
41-
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
40+
- name: Publish to NPM
41+
run: npm publish
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,14 @@ Note: When running Expo in a web browser, it will use the browser's locale setti
181181

182182
### TranslationConfig
183183

184-
| Property | Type | Required | Description |
185-
| ------------ | ------ | -------- | ------------------------------------------------------------ |
186-
| apiKey | string | Yes | Your API key for the translation service |
187-
| sourceLocale | string | No | Source locale for translations (will auto-detect if omitted) |
188-
| targetLocale | string | Yes | Target locale for translations |
189-
| cacheTTL | number | No | Cache validity period in hours (default: 24) |
184+
| Property | Type | Required | Description |
185+
| ------------ | ------ | -------- | -------------------------------------------- |
186+
| apiKey | string | Yes | Your API key for the translation service |
187+
| sourceLocale | string | Yes | Source locale for translations |
188+
| targetLocale | string | Yes | Target locale for translations |
189+
| cacheTTL | number | No | Cache validity period in hours (default: 24) |
190+
191+
**Tips**: When `sourceLocale` === `targetLocale` no translation requests will be send.
190192

191193
### useAutoTranslate Hook
192194

src/context/TranslationContext.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ export const TranslationProvider: React.FC<TranslationProviderProps> = ({
6868
(text: string, type?: string): string => {
6969
if (!text || loading) return text;
7070

71+
// Skip translation if source and target languages are the same
72+
if (config.sourceLocale === config.targetLocale) {
73+
return text;
74+
}
75+
7176
// Return cached translation if available
7277
const cachedTranslation = service.getCachedTranslation(text);
7378
if (cachedTranslation) return cachedTranslation;

0 commit comments

Comments
 (0)