Search code examples
ruby-on-railsinternationalizationrails-i18n

Does the keys in internationalisation rails behaves different if they are of different case


The example is from rails docs:

en:
 hello: "Hello world"

Are the both different. Does the case of the keys matters?

en:
 Hello: "Hello world"

Solution

  • Yes, case of the keys matters.

    check example,

    define variables in en.yml

    en:
      hello: "hello world"
      Hello: "HELLO WORLD"
    

    and access it from console as

    2.2.1 :001 > I18n.t('hello')
     => "hello world" 
    2.2.1 :002 > I18n.t('Hello')
     => "HELLO WORLD" 
    

    Please check Rails Internationalization