Grails i18n From Database but Default Back To File

后端 未结 5 1296
抹茶落季
抹茶落季 2020-12-08 03:49

Following this blog article I enabled my application to load i18n messages from the database. It works great. However, I don\'t want to manage all messages in the database

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 03:57

    I strongly encourage you to use Copycopter (http://copycopter.com) to manage i18n keys content. It will allow your team to update keys on the fly easily, using a friendly interface, and you will be able to set the default as you wanted. This way no one will come to you when a key needs to be updated.

    ThoughtBot, a strong web development consulting company is behind that product. It is solid.

    Your code will look like this then:

    mail :to => member.email,
         :subject => I18n.translate("member_mailer.reminder_to_sign_in.#{underscored_number_of_days}.subject",
                                    :default => %{You have not signed in for #{humanized_number_of_days}})
    

    The i18n keys are generated on the fly on copytcopter, the first time you use it. It is really easy to use.

    Check it out, it is worth it.

提交回复
热议问题