wesleytodd / YeoPress

A Yeoman generator for WordPress
Other
1.08k stars 163 forks source link

Create language folder and ask the user for the language variable #85

Closed felixzapata closed 10 years ago

felixzapata commented 10 years ago

Asks the user for the wp_language variable and creates the language folder inside the wp-content. This not download the language files from http://translate.wordpress.org.

A future feature it could be to obtain the files via curl from the following urls :

http://translate.wordpress.org/projects/wp/dev/admin/network/es/default/export-translations?format=mo http://translate.wordpress.org/projects/wp/dev/admin/network/es/default/export-translations?format=po

http://translate.wordpress.org/projects/wp/dev/admin/es/default/export-translations?format=mo http://translate.wordpress.org/projects/wp/dev/admin/es/default/export-translations?format=po

http://translate.wordpress.org/projects/wp/dev/twentytwelve/es/default/export-translations?format=mo http://translate.wordpress.org/projects/wp/dev/twentytwelve/es/default/export-translations?format=po

http://translate.wordpress.org/projects/wp/dev/twentythirteen/es/default/export-translations?format=mo http://translate.wordpress.org/projects/wp/dev/twentythirteen/es/default/export-translations?format=po

http://translate.wordpress.org/projects/wp/dev/twentyfourteen/es/default/export-translations?format=mo http://translate.wordpress.org/projects/wp/dev/twentyfourteen/es/default/export-translations?format=po

http://translate.wordpress.org/projects/wp/dev/twentyten/es/default/export-translations?format=mo http://translate.wordpress.org/projects/wp/dev/twentyten/es/default/export-translations?format=po

http://translate.wordpress.org/projects/wp/dev/twentyeleven/es/default/export-translations?format=mo http://translate.wordpress.org/projects/wp/dev/twentyeleven/es/default/export-translations?format=po

where 'es' is part of the language variable... the problem is the urls changes from one language to another... for example, portuguese it´s not 'pt-pt/', it´s only 'pt/'.

Languages can be checked from here http://translate.wordpress.org/projects/wp/dev

wesleytodd commented 10 years ago

Where do the files you linked to go? In the wp-content/languages folder? I have merged your changes, but I want to add the suggestion you mentioned about downloading the .mo and .po files.

There was also #81 requesting this, so since you showed me where to get the files, I will add this.

felixzapata commented 10 years ago

Hi, yes... all the files must be on the wp-content/language folder. Only the files for the themes (twentytwelve, twentythirteen, twentyfourteen, twentyeleven) has to be inside the wp-content/languages/themes. (You can check this if you download any language WordPress version)

Once the files are in the folder is enough... no more configuration is needed. The WordPress should show, after the installation, the correct language choose by the user.

If the user choose "es_ES" the wp_language variable will be "es_ES". So, in the function I´ve created yesterday, if you take the "es" value from the string you can uses for the urls.

The problem is witch part do you have to take from the string? If you take a look at the translate WordPress url, you will see different urls (different patterns) for every language.

Another example, if the user choose Australian english (I think that the correct value should be en_AU) the url should contains "en-au"... but if the user want the Galician WordPress version the variable will be "gl_ES" but the url must contains only "gl". You know what I mean?. If the url always had the same value as the wp_language variable, there would be no problem.

I think that the system for automatic download the languages files isn´t work all the times... Sometimes because the user choose an invalid variable... and othertimes because the url doesn´t follow a pattern (the main languages will works).

That´s the reason I only made a pull request with the folder creation. In a few weeks I have a WordPress meetup and I will meet people related with the Spanish translate group. I can ask them about the urls.

Or maybe you think a valid solution for the url problem ;)

wesleytodd commented 10 years ago

@felixzapata Thanks for the great explanation. I think we can solve this by trying the full locale code first, es-es, and if that returns a 404, then we try just es. So if the user entered gl_ES we would try these files:

  1. http://translate.wordpress.org/projects/wp/dev/admin/gl-es/default/export-translations?format=mo
  2. http://translate.wordpress.org/projects/wp/dev/admin/gl/default/export-translations?format=mo

Sound correct?

wesleytodd commented 10 years ago

On a separate note, #86 Translating the prompts

felixzapata commented 10 years ago

hummm... it may be a solution ;)

wesleytodd commented 10 years ago

If you are interested in checking it out, I got this working in the develop branch. It seems to work pretty well.

felixzapata commented 10 years ago

Great, I will check it when I get home

wesleytodd commented 10 years ago

I actually released this in version 1.4.0, so you can just update your generator-wordpress and you will be good to go. It is behind the --advanced flag.

felixzapata commented 10 years ago

It´s works but I use it without the flag (it´s ok?)... I´ve tested a Spanish WordPress instalation ... I´m going to make a pull request with a minor refactor related with the declaration of same variables...

tiptronic commented 10 years ago

@wesleytodd: What did you mean by 'I actually released this in version 1.4.0'... I can't seem to get a language file installed for me. Do you have any example? Should it work to localize/translate the admin area as well?

felixzapata commented 10 years ago

hi, yesterday I installed the generator again and did not ask me for the language installation.