Ken Webb 2013-04-13T15:06:02Z
Web App Frameworks as Graph-Based Software - YAML Locales
Ruby on Rails apps (Rails 3) use locale files to provide text in one or more human languages. They typically use YAML, a standard way of representing tree structures. The leaf nodes in the tree are key/value pairs.
For example, see the adopt-a-tree locale files.
Here's what the Rails locale structure looks like when it's been read in by Xholon, using the Java Jackson YAML library:
The Xholon model can then be exported in a wide range of formats. The following is part of the French-language (fr) locale text, exported in JSON format:
{"buttons":{ "Attribute_String":{ "roleName":"abandon", "Text":"Abandonner cet %{thing}" }, "Attribute_String":{ "roleName":"adopt", "Text":"Adopter!" }, "Attribute_String":{ "roleName":"back", "Text":"Retour" }, "Attribute_String":{ "roleName":"change_password", "Text":"Changer mon mot de passe" }, "Attribute_String":{ "roleName":"close", "Text":"Fermer" }, "Attribute_String":{ "roleName":"edit_profile", "Text":"Modifier le profil" }, "Attribute_String":{ "roleName":"email_password", "Text":"Envoyez-moi mon mot de passe" }, "Attribute_String":{ "roleName":"find", "Text":"Trouver %{thing}" }, "Attribute_String":{ "roleName":"send_reminder", "Text":"Envoyer un rappel à l'eau" }, "Attribute_String":{ "roleName":"sign_in", "Text":"Connexion" }, "Attribute_String":{ "roleName":"sign_out", "Text":"Inscription sur" }, "Attribute_String":{ "roleName":"sign_up", "Text":"S'inscrire" }, "Attribute_String":{ "roleName":"update", "Text":"Mise à jour"}}}
Return to Web App Frameworks as Graph-Based Software.