Well, I don't know about some preferred way, but I know how the language module of SHPS works:
- It uses a relational DB to store languages, language-groups (, ideally language-identifiers) and strings in different languages. So you could query the DB for a string in group "foo", identified by "bar" which is marked as language "en". The different parts shoud be stored in normalized tables:
- language(ID, name) which contains all supported languages (e.g. "en")
- language-group(ID, name) which contains all groups (e.g. "menu")
- language-identifier(ID, name) which contains all identifiers (e.g. "home")
- language-string(languageID, group, identifier, content) which stores the string by tieing it to a language, group and identifier.
- Inside, SHPS uses a state object for the request which contains stuff, like request and response headers.
- One could use the SHPS language module by calling
lang.getString(requestState, 'group', 'identifier') to get the string. I think that's quite convenient, as the method internally processes the state, determines the db and language to use (the browser usually sends several weighted possibilities, and if you support none, you have to use a fallback language, like English), does the actual querying and just returns the string. Well, actually SHPS returns a promise, though you might return a monadic Result or "default string" for error handling as well.