matice
matice copied to clipboard
Fallback locale not working
Situation: the locale is "de", the fallback locale is "en" and there are only translations for "en"
Expected behavior
calling the trans(
function should output an 'en' translation
Current behavior
matice throws a Locale [de] does not exist.
error.
This happens because the findSentence
immediately calls the translations
function which does not check the fallbackLocale
variable and thus fails.
Versions
- Laravel: 8.75.0
- Matice: 1.1.6
Hi! Let me take a look,
Are you using the CDN or the NPM package ?
Are you using the CDN or the NPM package ?
Npm package, newest version
Are you still having the same problem with this version?
Are you still having the same problem with this version?
I will check when I get back home 👍
Alright. Waiting...
@GENL
For the npm bundle I'm using the latest version 1.1.4, checked with npm view matice
For the composer package I'm using the latest version 1.1.7, checked with composer show genl/matice
As expected, still receiving the Locale [de] does not exist.
Error because the findSentence
function immediately calls the translations
function which does not check the fallbackLocale
variable and thus fails.
https://github.com/GENL/matice/blob/1.1.x/src/js/Localization/core.ts#L60
I've found a way to solve this issue for now.
Matice needs at least one translation file for any locale you want to specify. For now you can add a directory with your locale and php-file inside with the following content:
<?php
# resources/lang/de/placeholder.php
return (object) [];
This allows the fallback to work correctly. No the prettiest solution, but it works.