Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance the module to Properly respond to parametrised messages #6

Open
gabipetrovay opened this issue Sep 3, 2014 · 3 comments
Open

Comments

@gabipetrovay
Copy link
Contributor

Enhance the translate function as follows:

  • if messageToTranslate is a string, search it in the translations (already implemented)
  • if messageToTranslate is an Object, it must have the format:
{
  "message": "bla bla bla",
  "args": [1, 2, "bla"]
}

In this case, the message key will be searched for in translations. If the text contains %1, %2, %3, etc., they will be replaced from the args array with the argument in the array at position i-1. %N where N > args.length will be ignored (i.e. not replaced at all)

@gabipetrovay
Copy link
Contributor Author

Test this by sending the errors in this new format from sag-admin (i.e. CRM -> Activate new GP -> provide an empty domain name).

@IonicaBizau
Copy link
Member

I'd recommend using {0-...} (e.g. Hello {0}).

Get some inspiration from here. We already have this implemented in Ladivina application

@gabipetrovay
Copy link
Contributor Author

I agree. Then I recommend:

  • add it to Utils: function mergeArgs(text, args) { ...; return text; }
  • adjust the sag-admin module to use this format:
{
  "message": "bla bla bla",
  "params": [1, 2, "bla"]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants