Hello.
Today I've seen on github that somebody has pushed some files with the translation of some strings of drupalgap. I would like to contribute with some languages if possible, since I'm not able to contribute under the pure coding aspect... lacking skills :(

If Tyler or others can give me a hint about how to to, if there are templates to use, etc, I will begin the new translations
Thanks,
Kinmen

Comments

tyler.frankenstein’s picture

Status: Active » Closed (works as designed)

@kinmen, thank you for offering to help! Here's the easiest way to contribute to DrupalGap core translations:

  1. Fork the repo on GitHub: https://github.com/signalpoint/DrupalGap
  2. Add a [language-code].json file in the locale directory, if it doesn't already exist. Here are some examples: https://github.com/signalpoint/DrupalGap/tree/7.x-1.x/locale - language code list: https://api.drupal.org/api/drupal/includes%21iso.inc/function/_locale_ge...
  3. Look at es.json or tr.json for examples. It's just a JSON object, with the English string as the property, and the translation as the value. Use this format for all other language codes

Add this to your settings.js file, for example (using your language code instead):

// Language Files - locale/[language-code].json
drupalgap.settings.locale = {
   es: { }
};

And then set the actual language code in settings.js:

// The Default Language Code
Drupal.settings.language_default = 'es';

From here you can add translations for DrupalGap core (we'll be adding support for contrib/custom module translation very soon). When you're done, please submit a pull request on GitHub, then we can merge in your improvements and you'll receive credit as a contributor. Otherwise, you may send me the .json file for your language(s), and I can drop them in manually. But I'd recommend taking the time to learn how to fork/clone/commit/push/pull-request on GitHub.

kinmen’s picture

Ok, thank you. I'll begin to learn how github works, following your instructions. But I see that the strings in es.json and tr.json are different (inside the last there are "Confirm", "Member since", etc, in es.json those aren't written). Should I merge those 2 files (or better the strings in English from both files) to provide a complete translation? Last, are those strings just a part of the total to be translated or will be there others in the future? Thanks for your answer

K.

tyler.frankenstein’s picture

The language .json files are definitely incomplete, and not consistent with each other. You may add/edit translations accordingly. There are many translations missing from both, and some will have more than others, but feel free to merge them as needed, thanks.

kinmen’s picture

Thanks. Last thing what about language codes of json files for Chinese? There is traditional Chinese (zh-TW) and simplified (zh-CN), how should I name the json files? Is it ok for zh-tw.json or must the encode in the name of the file be of just 2 characters?
tnx,
K.

tyler.frankenstein’s picture

I think the file name can be any number of characters (not just two). So you should be able to do:

  • chi.json
  • zho.json

Then you can use the three character string in your settings.js file. I got these language codes from here: http://www.loc.gov/standards/iso639-2/php/code_list.php

Update, use these instead:

zh-hans.json
zh-hant.json
ptmkenny’s picture

Hey Tyler, I would suggest using the Drupal 7 list of language codes instead, which gives these values for traditional/simplified Chinese:

  'zh-hans' => array('Chinese, Simplified', '简体中文'),
    'zh-hant' => array('Chinese, Traditional', '繁體中文'),

https://api.drupal.org/api/drupal/includes%21iso.inc/function/_locale_ge...

Very happy to see the work on translations!

kinmen’s picture

I've just written a pull request on github for my first language file

tyler.frankenstein’s picture

Thank you @ptmkenny (Patrick), we'll now defer to the listing from Drupal that you provided when generating language code files.

@kinmen, I've merged in your pull request, thank you for the contribution!

For all, I've started a page in the docs to outline translation: http://drupalgap.org/translate

tyler.frankenstein’s picture

We now have support for contrib/custom modules to provide their own translations. See the docs for more details: http://drupalgap.org/translate

kinmen’s picture

Hello. Will there be in the future an option to let the end user chose the desired language in the (phone) application? Or a way to detect the system language of the smartphone?

Although the easier approach for the end user could be to let the smartphone chose the system language, somebody could prefer to switch to another language. I'm pretty sure somebody already have thought about that possibility, but which way will Drupalgap follow?

tyler.frankenstein’s picture

@kinmen, I picture this as a contributed module for DrupalGap. I personally would call it something like "Language Picker" and have it implement the features you mentioned. However, no clients of mine need it now, so I'll defer to anyone who wants to contribute to its resolution.

ptmkenny’s picture

@kinmen @tyler.frankenstein I think this should be a new issue: #2491803: Language selection code examples

kinmen’s picture

Hello.
I think that I've found a little bug. A "SyntaxError: missing : after property id" error has occurred when I've tried to include the Chinese translations in the settings.js file. I think this happened because javascript syntax doesn't like the "-" in zh-hant & zh-hans. Converting "-" in "_" in settings.js and in the name of the json files has solved the problem. If it's correct, this should be changed in Github

tyler.frankenstein’s picture

Status: Closed (works as designed) » Needs work

@kinmen yes, that is correct, we should not be using a hyphen in an object's property name, and converting to an underscore would likely solve it. Will you please file an issue and/or pull request with the SDK to resolve this?

kinmen’s picture

Yes, I'll issue a pull request to your Github

tyler.frankenstein’s picture

Status: Needs work » Closed (fixed)

Pull request merged.