2

I have created my own custom module. All of my outputted strings are wrapped in t functions. I have enabled Locale in core. I need to alter some of my module's strings and some field labels too, slightly, just a word here and there, form British English into US English.

What I'm trying to acheive is: if my site is being viewed in the US I want that to be automatically detected, and the adjusted strings/field labels displayed.

Thanks.

Solution: Install ip2country module. This provides a function called ip2country_get_country which returns an ISO 3166 two-character country code based on the user's IP address. Create a helper function that returns a boolean TRUE/FALSE is the country code is 'US'. Then just use if-else constructs to translate the required text.

0

First, I'm not sure about what this means "I cannot see any of the strings from my custom module." ... so my answer here may not be useful. but here goes:

Machines don't care about what the similarities are, variations of english might as well be chinese and spanish.. which works in our favour here!

Assuming (US) english is your primary/default language, translate only the strings you want in to the Queen's English: admin/config/regional/translate/translate

You may have to do some interesting stuff to make detection/selection work, but I think that's a new question.

  • When I navigate to admin/config/regional/translate/translate the filters are: Language: All | Search in: Both | Limit to: All. Only approx. 30 strings are listed. The first is: 'An AJAX HTTP error occurred.' from the text group 'Built-in interface'. Should I be seeing many more? The language is set to: English (built-in). Is that US English? Thanks. – 24ma13wg Feb 11 '14 at 15:34
  • the default is "english", afaik there's no "US English" or "British English".. that's where your detection will ahve to get interesting. I would suggest reading up on "localizing drupal"... treat it all as you might for a new language, but only translate those strings you need to translate. – jdu Feb 11 '14 at 18:23
0

There are two modules that may help you:

stringoverrides

or

stringoverrides_advanced

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.