Document how to unset and change the fallback locale for i18n
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- php, symfony
- Domain
- documentation, internationalization
Research direction
Start with the existing developer documentation and the _config.php example using MessageProvider and Injector; compare it with the Symfony TranslatorInterface configuration shown in the issue. Document how to unset and change the fallback locale, including the default-locale behavior and both configuration approaches, and ensure the examples explain the expected translation result.
Written by the indexing model from the issue text.
Description
Affected Version
Framework 4.13.10 and probably up
Description
Note: See comments for a clear indication of what needs to be documented.
When translating keywords in templates with <%t MyClass.MyKeyword "My Default Value" %> and the default language is not EN then the Default Value will not be displayed but instead the value of the English language file will be shown if the MyClass.MyKeyword is not in the language yml file of the (non english) default language.
It should fall back to the default - not the English version. So not expected behavior.
Steps to Reproduce
Create nl.yml file and add nothing
Create en.yml file and add: MyClass.MyKeyword: 'MY ENGLISH VALUE'
Set locale to NL and test in template with <%t MyClass.MyKeyword "My Default Value" %>
'MY ENGLISH VALUE' will be shown instead of 'My Default Value'
Fix with Injector
Override the FallbackLocales value of Symfony\Component\Translation\TranslatorInterface this should be set to the default language and not to English. In this example the setFallbackLocales language is set to dutch language NL.
---
Name: resettranslatorinterface
---
SilverStripe\Core\Injector\Injector:
Symfony\Component\Translation\TranslatorInterface: false
---
Name: overridetranslatorinterface
---
SilverStripe\Core\Injector\Injector:
Symfony\Component\Translation\TranslatorInterface:
class: Symfony\Component\Translation\Translator
constructor:
0: 'en'
1: null
2: '`TEMP_PATH`'
properties:
ConfigCacheFactory: '%$Symfony\Component\Config\ConfigCacheFactoryInterface'
calls:
FallbackLocales: [ setFallbackLocales, [['nl']]]
Loader: [ addLoader, ['ss', '%$Symfony\Component\Translation\Loader\LoaderInterface' ]]
Fix with _config.php
$provider = Injector::inst()->create(MessageProvider::class);
$provider->getTranslator()->setFallbackLocales(['nl']);
- Dominant language
- No language data
- Stars
- 7
- Forks
- 74
- Avg merge
- 1d 14m
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from silverstripe/developer-docs
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
silverstripe/developer-docs#911 ·
-
Read-only replicas: config key is rule_patterns_must_use_primary_db, not must_use_primary_db_rules Open
Difficulty 1/5 Under an hour Newbie friendliness 92/100
silverstripe/developer-docs#909 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
silverstripe/developer-docs#908 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
silverstripe/developer-docs#907 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
silverstripe/developer-docs#903 ·
All issues in silverstripe/developer-docs
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
agilepathway/label-checker#640 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
amponce/archive-movie-browser#167 ·
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·