0

For example, suppose my app have some localized text, my question is , should the key contain actual context of text:

{
    "WELCOME_TO_USE_THIS_APP":{
      "en":"Welcome to use this app,...",
      "es":"Bienvenido a usar esta aplicación, ..."
    }
}

or the meta information about the text

{
    "WELCOME_MESSAGE":{
      "en":"Welcome to use this app,...",
      "es":"Bienvenido a usar esta aplicación, ..."
    }
}

?

  • Both methods are successfully being used by different localization systems. That makes the question essentially unanswerable. – Bart van Ingen Schenau Aug 1 '18 at 6:23
1

Both methods are problematic.

If we choose WELCOME_TO_USE_THIS_APP but then decide to change the message, to for example "Thanks for choosing our app" the key no longer fits

If we choose WELCOME_MESSAGE and use it in more than one place it will soon become WELCOME_MESSAGE and WELCOME_MESSAGE_2 and then WELCOME_MESSAGE_3 as we have slightly different versions in different contexts. perhaps "Welcome to choose this app" and "welcome to choose this application." etc

I think the best approach is to be very specific and have a one to one mapping to a particular View or Page

WelcomePage.Title
WelcomePage.Heading

This way our keys should only change when the view that uses them changes, and the text can be chosen specifically with the constraints of the view in mind, such as character limit, font size etc.

0

I would use the source language text as the key. The extra name serves no real purpose in most cases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.