Comments (4)
Hi, and thanks for your suggestion !
Apart from the breaking change, I see different problems with this implementation.
If the locale isn't defined, it will do the following :
table[""] = {};
I don't feel good with empty string as prop, so it implicates to set a default value to the locale (en ?) to avoid the problem.
It will also break people who wrote the set()
before the locale()
thinking there is no internal relations:
set({
test: 'test',
// ...
});
locale('xx');
And will certainly cause problem with asynchrone JSON loading and locale()
updates during this time causing the table to be set in the wrong namespace.
My opinion on this one is too keep it verbose to avoid problems.
from frenchkiss.js.
Hmmm 🤔,
I don't like "verbose" things, but even if we assume a default value to locale
based on browser language, see the below code, we will have problems with async JSON loading =(
let _locale = !languages[navigator.language]
? languages[navigator.language.substr(0, 2).toLowerCase()] ||
'en',
: languages[navigator.language];
from frenchkiss.js.
In my opinion, it's not up to this library to check the user language. All websites have different rules to determine it, and the browser language is most of the time the last verification they do, in the order :
- hl query parameter.
- fb_locale query parameter.
- account language (session, cookie)
- language folder in the url
- language dns the url
- browser language
If you really want something that doesn't lead to errors and don't duplicate commands it will be better to configure the table and the locale at the same time, only one function needed.
Something like (not implemented) :
frenchkiss.init({
locale: 'en',
fallback: 'fr',
messages: {
en: {
test: 'test'
},
fr: {
test: 'test'
};
}
});
from frenchkiss.js.
Yeah, I agree with you:
it's not up to this library to check the user language 👍
let maybe? = 'keep it verbose is the best approach to avoid problems.';
from frenchkiss.js.
Related Issues (12)
- Extraction Tool HOT 6
- "I did not bought apples!" is not English HOT 1
- [Suggestion] Add typescript support
- CSP compatibly HOT 3
- [Suggestion] Add support for nested objects HOT 1
- [Suggestion] pass params to onMissingKey HOT 1
- [Feature Request] Export the getCompiledCode method HOT 3
- Can the key be considered as a fallback to a language HOT 1
- Code generation from strings disallowed for this context
- Add github actions to validate PRs through the tests
- Ordinal suffix configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from frenchkiss.js.