Skip to content

Instantly share code, notes, and snippets.

@krainboltgreene
Created June 4, 2012 06:50
Show Gist options
  • Save krainboltgreene/2866752 to your computer and use it in GitHub Desktop.
Save krainboltgreene/2866752 to your computer and use it in GitHub Desktop.
accounts_controller:
sign_out:
en: "Sign Out"
index_action:
no_ideas:
en: "You have no ideas, why don't you make some?"
es: "Usted no tiene ninguna idea, ¿por qué no hacer algo?"
posts_controller:
find_posts:
en: "Find Posts"
insufficient_funds:
en: "You don't have sufficient funds."
jp: "あなたが十分な資金を持っていません。"
en:
accounts_controller:
sign_out: "Sign Out"
index_action:
no_ideas: "You have no ideas, why don't you make some?"
posts_controller:
find_posts: "Find Posts"
insufficient_funds: "You don't have sufficient funds."
es:
accounts_controller:
index_action:
no_ideas: "Usted no tiene ninguna idea, ¿por qué no hacer algo?"
jp:
insufficient_funds: "あなたが十分な資金を持っていません。"
{
"accounts_controller": {
"sign_out": {
"en": "Sign Out"
},
"index": {
"no_ideas": {
"en": "You have no ideas, why don't you make some?",
"es": "Usted no tiene ninguna idea, ¿por qué no hacer algo?"
}
}
},
"posts_controller": {
"find_posts": {
"en": "Find Posts"
}
},
"insuficient_funds": {
"en": "You don't have sufficient funds.",
"jp": "あなたが十分な資金を持っていません。"
}
}
{
"en": {
"accounts_controller": {
"sign_out": "Sign Out",
"index_action": {
"no_ideas": "You have no ideas, why don't you make some?"
}
},
"posts_controller": {
"find_posts": "Find Posts"
},
"insufficient_funds": "You don't have sufficient funds."
},
"jp": {
"insufficient_funds": "あなたが十分な資金を持っていません。"
},
"es": {
"accounts_controller": {
"index_action": {
"no_ideas": "Usted no tiene ninguna idea, ¿por qué no hacer algo?"
}
}
}
}
@krainboltgreene
Copy link
Author

(not quite sure what you mean by your last point about not lending to database representation)

Representing the locales structure in a document database does not work if you have language as root. You end up with a finite list of root documents (languages) and infinite key/values. The other way you have infinite documents (the identifiers) with finite key/values (the locales and their respective text).

However, it also means you have to bundle all your locales into one huge bundle.

This happens anyways, you always have to bundle the entire thing into a single structure (with multiple root nodes). In this case, however, you can have infinite root nodes. I always suggest having global, controller specific, and controller+action specific.

But there's still the issue that it's confusing to have 10 or 20 different languages in a row for each attribute

I'm not sure that's an issue, I would have to ask a translator. You could always have a default be a specific language:

{
  "posts_controller": "Red Light"
}

instead of

{
  "posts_controller": { "en": "Red Light" }
}

I think ultimately a preprocessor is overkill. Having simple json files with the end nodes identifying the language would require less work and ultimately less magic.

@krainboltgreene
Copy link
Author

Oh, and example of the database version is things like Copycopter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment