-
-
Notifications
You must be signed in to change notification settings - Fork 38
docs: add CLI FAQ and document key management limitations #996
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
Open
dzienisz
wants to merge
2
commits into
main
Choose a base branch
from
feat/cli-limitations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+157
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,6 @@ module.exports = { | |
], | ||
}, | ||
'migration-to-v2', | ||
'faq', | ||
], | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
--- | ||
id: faq | ||
title: Frequently Asked Questions | ||
--- | ||
|
||
This page addresses common questions and misconceptions about the Tolgee CLI. | ||
|
||
## Key Management and Default Values | ||
|
||
### Q: Does the CLI detect duplicate keys with different default values? | ||
|
||
**A: No, currently the CLI does not detect this scenario.** | ||
|
||
If you have the same key with different default values in your code: | ||
|
||
```jsx | ||
<T keyName="save-btn" defaultValue="Save" /> | ||
<T keyName="save-btn" defaultValue="Save (Changed)" /> | ||
``` | ||
|
||
The CLI will not warn you about this conflict. This is a known limitation that may be addressed in future versions. | ||
|
||
**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. | ||
|
||
### Q: Why don't default values automatically update my base language translations? | ||
|
||
**A: This is by design to prevent conflicts between code and platform translations.** | ||
|
||
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: | ||
|
||
- A developer changes a default value in code | ||
- A translator or PM has already refined the wording in the platform | ||
- The two sources of truth conflict with each other | ||
|
||
### Q: How can I search for strings in my code if I only use keys and not default values? | ||
|
||
**A: This depends on your approach to translation management.** | ||
|
||
If you follow Tolgee's recommended approach of using the platform as the single source of truth: | ||
- **Best approach**: Use in-context editing (available only for native JS SDKs with DevTools plugin) to click directly on the string in your app, then search for the key | ||
- **Alternative**: Search for keys in your code: `grep -r "save-btn" src/`, then look up the actual translation in the Tolgee Platform | ||
|
||
If you maintain fallback translations in your code: | ||
- You can search for both keys and translation strings | ||
- But you'll need to manage consistency between code and platform | ||
|
||
## Best Practices and Workflow | ||
|
||
### Q: Should I keep default values in my code? | ||
|
||
**A: Tolgee recommends against using default values as the source of truth.** | ||
|
||
Here's why: | ||
- **Single source of truth**: Having translations in both code and platform creates confusion | ||
- **Team collaboration**: PMs, UX designers, and translators can update wording directly in the platform | ||
- **Consistency**: Prevents conflicts between developer changes and translator/PM changes | ||
|
||
**Recommended approach**: Use keys without default values, and rely on the Tolgee Platform for all translation content. | ||
|
||
### Q: How should I handle translations in production? | ||
|
||
**A: NEVER use API keys in production. You have two recommended options:** | ||
|
||
**Option 1: Export translations as static assets** | ||
1. Use `tolgee pull` to download translations to local files during your build process | ||
2. Bundle these files with your application | ||
3. Keep these files in version control | ||
4. Update them regularly via `tolgee pull` in your CI/CD pipeline | ||
|
||
**Option 2: Use Tolgee Content Delivery** | ||
- Configure your app to load translations from Tolgee's Content Delivery using the `BackendFetch` plugin | ||
- No API keys required in production | ||
- Automatic updates when translations change (up to 15 minutes for global CDN propagation) | ||
|
||
Both approaches give you: | ||
- No API key exposure in production | ||
- Reliable performance without direct platform dependency | ||
- Platform as single source of truth during development | ||
|
||
### Q: How do I handle the workflow where I want to update translations from code? | ||
|
||
**A: Update translations directly in the Tolgee Platform, not in code.** | ||
|
||
Instead of changing default values in code: | ||
1. Update the translation in the Tolgee Platform UI | ||
2. Use the platform's features like translation memory, suggestions, and collaboration | ||
3. Pull the updated translations to your local files if needed | ||
|
||
This workflow: | ||
- Keeps the platform as the authoritative source | ||
- Allows non-developers to manage translations | ||
- Prevents conflicts and inconsistencies | ||
|
||
## Technical Limitations | ||
|
||
### Q: Should I avoid having multiple keys with the same translation text? | ||
|
||
**A: No, Tolgee actually recommends against de-duplication of translation strings.** | ||
|
||
While some developers worry about translating the same phrase multiple times (e.g., having both `save-btn` and `submit-btn` keys with the text "Save"), this is actually beneficial because: | ||
|
||
- **Context matters**: The same text can have different meanings in different contexts | ||
- **Future flexibility**: You may want to change the wording in one place but not another | ||
- **Semantic clarity**: Keys should represent their purpose, not just their current text | ||
|
||
For example, `save-document` and `save-settings` might both currently say "Save", but you may later want to change one to "Save Document" while keeping the other as "Save". | ||
|
||
### Q: Can I force the CLI to update base language translations from default values? | ||
|
||
**A: No, this is not supported and goes against Tolgee's recommended workflow.** | ||
|
||
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.