Skip to content

Commit 3ad3ca2

Browse files
committed
docs: add CLI FAQ and document key management limitations
1 parent b995ba6 commit 3ad3ca2

File tree

4 files changed

+146
-0
lines changed

4 files changed

+146
-0
lines changed

sidebarTolgeeCli.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ module.exports = {
1818
],
1919
},
2020
'migration-to-v2',
21+
'faq',
2122
],
2223
};

tolgee-cli/extraction/syncing-strings.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,31 @@ When running this command on CI, the CLI automatically adds review annotation wa
3535
See an example [here](https://github.com/tolgee/tolgee-platform/commit/ddfff41#diff-84dc9ca52993f2d66eda975f622361460f83d659ce6ddf1a0c086e6ca8c328ccR46).
3636
:::
3737

38+
### Duplicate key detection limitations
39+
40+
Currently, the CLI does **not** detect when the same key appears multiple times in your code with different default values. For example, if you have:
41+
42+
```jsx
43+
<T keyName="save-btn" defaultValue="Save" />
44+
<T keyName="save-btn" defaultValue="Save (Changed)" />
45+
```
46+
47+
The CLI will not warn you about this conflict. This is a known limitation that may be addressed in future versions.
48+
49+
**Workaround**: Use consistent default values across your codebase, or rely on the Tolgee Platform as the single source of truth for translations rather than default values in code.
50+
51+
### Default values and base language behavior
52+
53+
When you first sync a key with a default value, the CLI will create the key in your Tolgee project and set the default value as the translation for your base language. However, **subsequent changes to default values in your code will not automatically update the base language translation** in Tolgee.
54+
55+
For example:
56+
1. You add `<T keyName="welcome" defaultValue="Welcome" />` and run `tolgee sync`
57+
2. Tolgee creates the key "welcome" with "Welcome" as the English (base language) translation
58+
3. Later, you change the code to `<T keyName="welcome" defaultValue="Welcome Back" />`
59+
4. Running `tolgee sync` again will **not** update the English translation to "Welcome Back"
60+
61+
This is by design to prevent conflicts between code changes and translations managed in the Tolgee Platform.
62+
3863
## Comparing projects
3964

4065
You can think of this utility as a dry-run of `tolgee sync`. You can use it to see the added/removed strings and

tolgee-cli/faq.mdx

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
id: faq
3+
title: Frequently Asked Questions
4+
---
5+
6+
This page addresses common questions and misconceptions about the Tolgee CLI.
7+
8+
## Key Management and Default Values
9+
10+
### Q: Does the CLI detect duplicate keys with different default values?
11+
12+
**A: No, currently the CLI does not detect this scenario.**
13+
14+
If you have the same key with different default values in your code:
15+
16+
```jsx
17+
<T keyName="save-btn" defaultValue="Save" />
18+
<T keyName="save-btn" defaultValue="Save (Changed)" />
19+
```
20+
21+
The CLI will not warn you about this conflict. This is a known limitation.
22+
23+
**Recommended approach**: Use consistent default values across your codebase, or better yet, rely on the Tolgee Platform as the single source of truth for all translations.
24+
25+
### Q: Why don't default values automatically update my base language translations?
26+
27+
**A: This is by design to prevent conflicts between code and platform translations.**
28+
29+
When you first sync a key, the default value becomes the base language translation. However, subsequent changes to default values in code will not update the platform translation. This prevents situations where:
30+
31+
- A developer changes a default value in code
32+
- A translator or PM has already refined the wording in the platform
33+
- The two sources of truth conflict with each other
34+
35+
### Q: Can I search for strings in my code if I only store keys?
36+
37+
**A: This depends on your approach to translation management.**
38+
39+
If you follow Tolgee's recommended approach of using the platform as the single source of truth:
40+
- You would search for keys in your code: `grep -r "save-btn" src/`
41+
- Then look up the actual translation in the Tolgee Platform
42+
43+
If you maintain fallback translations in your code:
44+
- You can search for both keys and translation strings
45+
- But you'll need to manage consistency between code and platform
46+
47+
## Best Practices and Workflow
48+
49+
### Q: Should I keep default values in my code?
50+
51+
**A: Tolgee recommends against using default values as the source of truth.**
52+
53+
Here's why:
54+
- **Single source of truth**: Having translations in both code and platform creates confusion
55+
- **Team collaboration**: PMs, UX designers, and translators can update wording directly in the platform
56+
- **Consistency**: Prevents conflicts between developer changes and translator/PM changes
57+
58+
**Recommended approach**: Use keys without default values, and rely on the Tolgee Platform for all translation content.
59+
60+
### Q: What about fallback translations for when the platform is unavailable?
61+
62+
**A: Use the pull command to maintain local fallback files.**
63+
64+
Instead of default values in code:
65+
1. Use `tolgee pull` to download translations to local files
66+
2. Configure your app to use these files as fallbacks
67+
3. Keep these files in version control
68+
4. Update them regularly via `tolgee pull`
69+
70+
This approach gives you:
71+
- Reliable fallbacks without CDN dependency
72+
- Platform as single source of truth
73+
- Automatic updates via CLI
74+
75+
### Q: How do I handle the workflow where I want to update translations from code?
76+
77+
**A: Update translations directly in the Tolgee Platform, not in code.**
78+
79+
Instead of changing default values in code:
80+
1. Update the translation in the Tolgee Platform UI
81+
2. Use the platform's features like translation memory, suggestions, and collaboration
82+
3. Pull the updated translations to your local files if needed
83+
84+
This workflow:
85+
- Keeps the platform as the authoritative source
86+
- Allows non-developers to manage translations
87+
- Prevents conflicts and inconsistencies
88+
89+
## Technical Limitations
90+
91+
### Q: Will duplicate key detection be added in the future?
92+
93+
**A: This is a known limitation that may be addressed in future versions.**
94+
95+
Currently, the CLI focuses on extracting keys and syncing with the platform. Enhanced validation features like duplicate detection are being considered for future releases.
96+
97+
### Q: Can I force the CLI to update base language translations from default values?
98+
99+
**A: No, this is not supported and goes against Tolgee's recommended workflow.**
100+
101+
The CLI is designed to treat the platform as the authoritative source for translations. If you need to update base language translations, do so directly in the Tolgee Platform.

tolgee-cli/introduction.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ You can find the **source code** of the CLI on [GitHub](https://github.com/tolge
1313
<source src="/tolgee-cli.webm"></source>
1414
</video>
1515

16+
## Best Practices
17+
18+
### Single Source of Truth
19+
20+
Tolgee recommends using the **Tolgee Platform as the single source of truth** for all translations, rather than maintaining default values in your code. This approach:
21+
22+
- **Prevents conflicts** between code changes and translator/PM updates
23+
- **Enables collaboration** - non-developers can manage translations directly
24+
- **Maintains consistency** across your entire localization workflow
25+
26+
### Recommended Workflow
27+
28+
1. **Extract keys without default values** from your code using the CLI
29+
2. **Manage all translation content** in the Tolgee Platform
30+
3. **Use `tolgee pull`** to download translations as local fallback files
31+
4. **Keep fallback files in version control** for offline functionality
32+
33+
This workflow decouples translation content from code, allowing your team to iterate on wording without requiring code changes.
34+
1635
## Features
1736

1837
### Easy project configuration

0 commit comments

Comments
 (0)