Comments (2)
the value of _id will be like en_US, fr_FR ....
First it will be easy to just get all supported languages: just select all from I18N - only get _id and lang_name keys
lang_name is just descriptive name like "English US"
All the records will have 'strings' object as nested object with string => value pairs
The I18N Class will be serializable and will go into user's SESSION for caching.
This is how it works:
Object holds $aLocale array. Object has $locale = en_US for example, to indicate which locate the strings are in.
Then to lookup a string we do this: if !array_key_exists($str, $this->aLocale) then fetch another array from Mongo, this time with default values for the "language-only", for example "en" and do the array_merge with aLocate.
Then if values still not found then fetch default lang array and merge it again.
Actually this can be just one step: fetch array in default lang, then fetch array in non-locate lang, for example if user's lang is en_GB we then select 2 records: 'en' and default lang - if default lang is not already the same as 'en'
We then merge the 3 arrays - Locale, default lang and default. The result is the Locale...
Me also set "merged" flag to "YES" to then if we still cannot find the string we don't do the step 2 again and instead
we will just use the string as value, at the same time adding it to Locale array - sort of like for caching...
The small possible problem is that admin adds new string(s) while peeps are still logged in and then they are using outdated array, but this is not really a big deal...
from lampcms.
What if we do one select where locate $in 'user's locate', 'no-locale-lang', 'default lang'. Then merge these 3 and that's our array! Put it into user's session and reuse! Can EVEN cache this result array in Cache to reuse between users! Just make sure to use the 'tag' in cache so it can be removed from cache easily by using tag.
from lampcms.
Related Issues (20)
- unanswered/tagged/ does not work properly HOT 1
- Category selection not saved when editor content is saved
- Update logger
- Backup DB and upload to offline storage
- Ability to change category when editing question HOT 1
- The Intro not updated when Question is edited HOT 1
- When MIN_QUESTION_TAGS set to 1 tags require tags not enforced HOT 1
- Make length of INTRO configurable
- Make it possible to run Lampcms on custom port number
- Remove ! from file names HOT 1
- Don't send passwords in cleartext email
- Templating docs HOT 1
- Can't ask or answer a question
- Registration Issue using WAMP
- PHP Mongo extension loaded, but LampCMS saying it's not
- New Youtube API Support
- PHP 7 HOT 1
- Cakephp
- Is the Project no longer maintained? HOT 1
- Trying to get in touch regarding a security issue HOT 4
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 lampcms.