What is the best way to organize i18n resource keys?

What is the best way to organize i18n resource keys by component?

FILE_TAB_TITLE:    'Files'
FILE_FIELD_TITLE:  'File'
GROUP_TAB_TITLE:   'Group'
GROUP_FIELD_TITLE: 'Group'
SAVE_MENU_ITEM:    'Save'
SAVE_AS_MENU_ITEM: 'Save as...'
SAVE_BUTTON:       'Save'

Or what do they mean?

FILE:    'File'
FILES:   'Files'
GROUP:   'Group'
SAVE:    'Save'
SAVE_AS: 'Save as...'
+5
source share
3 answers

I think this agreement is more than a rule, so the answer may be "anything that seems more logical."

I started creating my i18n resource keys and I accepted the following convention:

  • Header with "header" starting C #
  • Point split hierarchical notation
  • Keys arranged in alphabetical order for easy access

Example:

#File access
file.field.title = File
file.field.subtitle = Click here
file.tab.title = Files

#User
user.name = First and last name
user.password = Password
user.username = Username
+2
source

I use short, high versions of English phrases. For example (JavaScript):

SAVE: "Save",
LOAD: "Load",
PLEASE_SELECT_ITEM: "Please select an item.",
PRESS_NEXT_TO_PROCEED: "Please press the Next button to proceed."

, , , .

, (, "", ..), , .

, /, .

+2

I am sorting my function in a hierarchy like

ui:
  choose: choose...
  save: save
  cancel: cancel
  preview: preview

season:
  summer: summer
  autumn: autumn
  winter: winter
  spring: spring

people: !!pl
  0: no people
  1: one person
  n: "%1 people"

is_are_people: !!pl
  0: are no people
  1: is one person
  n: "are %1 people"

and then in my helpers, routes or haml files (I use mainly Sinatra). I can link to Unicode::capitalize(t.ui.save)in my save button and "There #{t.is_are_people some_people.count}."in my header, etc.

+1
source

All Articles