During today’s National Day of Civic Hacking in Charlotte, Jim van Fleet (co-captain for Code for Charlotte) showed off the NC Balance project to me and a few other new people. He was asked the question how it works with different languages, and we looked at the code and noticed the somewhat primitive if/else clauses in the message generator. We figured that we could make this better by using the Ruby i18n package instead.
This change does not change the messages in any way other than using I18n.t to translate them with. New languages can easily be added by adding a new case statement to the language assignment in MessageGenerator.initialize as well as a file in config/locales.
Added support for internationalization to alleviate if/else bloat.
Loading locales into Sinatra on initialization.
Updated specs to work with i18n and sinatra/i18n.
Updated message_generator.rb with I18n.t usage.
During today’s National Day of Civic Hacking in Charlotte, Jim van Fleet (co-captain for Code for Charlotte) showed off the NC Balance project to me and a few other new people. He was asked the question how it works with different languages, and we looked at the code and noticed the somewhat primitive
if
/else
clauses in the message generator. We figured that we could make this better by using the Rubyi18n
package instead.This change does not change the messages in any way other than using
I18n.t to
translate them with. New languages can easily be added by adding a new case statement to the language assignment inMessageGenerator.initialize
as well as a file inconfig/locales
.Added support for internationalization to alleviate if/else bloat. Loading locales into Sinatra on initialization. Updated specs to work with
i18n
andsinatra/i18n
. Updatedmessage_generator.rb
withI18n.t
usage.