#18200 closed task (blessed) (fixed)
Language Packs
Reported by: | nacin | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Upgrade/Install | Keywords: | 3.7-early has-patch |
Focuses: | Cc: |
Description (last modified by )
Implement language packs for core, plugins, and themes.
Inspiration and code can hopefully be derived from the corresponding GSoC project.
This will require quite a bit of work in GlotPress, on api.wordpress.org, and in core. I will take point, but assistance will be needed. A number of decisions will need to be made. I will begin designing a document for what exactly needs to be done over the next week.
Attachments (14)
Change History (124)
#5
@
13 years ago
A sanity check on my syntax for this patch would be appreciated. Untested and I may have missed a string.
#6
in reply to:
↑ 4
@
13 years ago
Replying to nacin:
Two files are currently hard-coded and committed into SVN by translators: setup-config.php, and wp-config-sample.php.
There's also:
- readme.html
$wp_default_secret_key
in default-constants.php (not required, but prevents the admin area from breaking after installing some plugins, see #14024 and the post on WP Polyglots)
Replying to nacin:
A sanity check on my syntax for this patch would be appreciated.
Tested installation, works fine. Minor correction in line 85:
'WordPress › Setup Configuration File'/*WP_I18N_SETUP_CONFIG_EXISTS*/;
Should be:
'WordPress › Setup Configuration File'/*/WP_I18N_SETUP_TITLE*/;
#16
@
13 years ago
- Keywords 3.4-early added
- Milestone changed from 3.3 to Future Release
It was decided at last week's dev chat to punt this because we are past freeze and it's not quite done. Hopefully it will be ready as soon as we open the 3.4 branch.
#28
@
12 years ago
Oh, dd32, why you didn't post a comment, we could have never seen this patch? :)
Anyway, I'll try to summarize what this patch does so you correct me where I'm wrong:
- On core/plugins/themes check for updates, we now check for languages too.
- Checks for languages are done by searching for language files in WP_LANG_DIR, from which is then PO-Revision-Date taken to be sent to api.wp.org.
- When any install/upgrade of core/plugin/theme is done, rechecks for updates are forced for everything so that there are fresh results against latest versions.
- After that, upgrades for available languages updates for everything (core/plugins/themes) are forced.
#30
@
12 years ago
Oh, dd32, why you didn't post a comment, we could have never seen this patch? :)
Because the patch is more than useless without the WordPress.org infrastructure being setup (And it wasn't set up, and still isn't ready). Those that needed to know there's a patch here knew about it :)
The overview of what you've said sounds about right for the process it'd be doing.
#31
@
12 years ago
- Milestone changed from Future Release to 3.5
Considering this for 3.5 for bundled themes and importers.
#36
@
12 years ago
- Milestone changed from 3.5 to Future Release
Language Packs are currently blocked by needing WordPress.org development, Shifting out of 3.5 since it won't be included.
#43
@
12 years ago
Non-blocking
I disagree that this needs to wait WordPress.org infrastructure before inclusion in core. The way this should work based on proposed patch is that when there is no WordPress.org infrastructure it won’t return anything language related so it would simply work as before.
This means that infrastructure might get ready late in release cycle, or even after release, and in that time we’ll have core side done and tested. Core support doesn’t require API (api.wordpress.org) support, it’s only required if you want to have it as an official feature.
Probably, in beginning there will be need for some change in API’s response so that response can be able to hold information for a few language-core/plugin/theme combinations that would have pre-made static language packages for testing purposes. This shouldn’t require too much changes.
Testing
I tested patch by @dd32. Everything in install/upgrade of core/plugins/themes worked as usual so there is nothing breaking. For packs, even if response had language information, nothing would happen since patch doesn’t save that data.
So I modified it (see attached patch) with presumption that structure of API responses is same. Response for core is already structured so that there are a couple of keys with different content and it would simply access one more for languages. Plugins and themes responses offer arrays where first level keys are names of plugins/themes so it just checks for language_updates key and unsets it.
Then I forced response to hold language information with pre-made packages (see attached plugin).
With language_updates available, upgrader would download and extract language files as expected.
Improvements
There are possible improvements to this core workflow:
- API responses for plugins/themes should change to be in line with core one (current array of updates can be under offers key, with languages under language_updates).
- API requests should have one more key along installed_languages that carries language codes so that site can get language files even if there aren’t installed language files.
- On unistallation of plugin/theme, associate language files should be deleted too.
- Action links on upgrader screen should be maybe shown after language updates are done to avoid possible interruption caused by user’s click on those links.
GlotPress
On GP side, I added some related patches, like introducing hooks when translation is changed (to rebuild package) or projects branching. I have other ideas for GP improvements but that’s blocked by lack of any development over there.
Conclusion
I propose that core support for language packs lands early in 3.6 cycle. This would give enough time for testing and shift attention to WordPress.org and GlotPress since they need a lot more changes.
@
12 years ago
Plugin used to test attachment:ticket:18200:lp.5.diff as described in comment:ticket:18200:43
#46
@
11 years ago
- Keywords 3.7-early added; 3.4-early removed
- Milestone changed from 3.6 to Future Release
- Owner set to nacin
- Status changed from new to accepted
#52
@
11 years ago
I've refreshed patch against latest revision.
Note that attachment:ticket:18200:no_plugin_overwrite.patch doesn't need refreshing and I see no reason why this can't go immediately since we have this feature for themes since 3.5.
#61
follow-up:
↓ 62
@
11 years ago
In 25536, shouldn't $new_update->translations
also be set to an empty array if the response fails (similar to $new_update->response
)?
#62
in reply to:
↑ 61
@
11 years ago
Replying to rmccue:
In 25536, shouldn't
$new_update->translations
also be set to an empty array if the response fails (similar to$new_update->response
)?
A bit related:
Notice: Undefined index: translations in wp-includes/update.php on line 230
#64
@
11 years ago
Notice: Undefined index: translations in wp-includes/update.php on line 230
That should be fixed now I think, for about half an hour after that initial commit the API wasn't returning the field. It is now, so it shouldn't hit that condition.
#67
@
11 years ago
- Cc netweb added
#bbPress2437 Test and ensure support within bbPress plugin for WordPress Core #WP18200 :)
@
11 years ago
What delete_plugins() might need to delete language files. Let's ignore this entirely for now. If we wanted to, we could clear up unused language files on a future update.
#71
follow-up:
↓ 73
@
11 years ago
In 23912: WP_Upgrader: Add upgrader_process_complete hooks and add a abort_if_destination_exists flag (default is true). props dd32. see #18200.
I just noticed that upgrader_process_complete
passes the 3rd arguement as $plugin or $theme (ie. the item to update), where as core passes $result, the result of the upgrade process.
As a result, only Core upgrades are able to detect if the upgrade failed.
I noticed this because Upon a core upgrade failing, Language packs proceed to try to update themselves, thus, a method to detect core, plugin, and theme update failures via the filter would be good.
#73
in reply to:
↑ 71
@
11 years ago
Replying to dd32:
In 23912: WP_Upgrader: Add upgrader_process_complete hooks and add a abort_if_destination_exists flag (default is true). props dd32. see #18200.
I just noticed that
upgrader_process_complete
passes the 3rd arguement as $plugin or $theme (ie. the item to update), where as core passes $result, the result of the upgrade process.
As a result, only Core upgrades are able to detect if the upgrade failed.
I noticed this because Upon a core upgrade failing, Language packs proceed to try to update themselves, thus, a method to detect core, plugin, and theme update failures via the filter would be good.
I think we should shift $plugin and $theme to argument 4, and make $result always the third argument. Or, we could set the $package to be the third argument for core updates, and make $result always the fourth argument. Either way.
For bulk plugins/themes, is a single $result all we need? Or is it an array of results? I think we should still try to update languages even when something goes wrong in bulk.
#74
follow-up:
↓ 75
@
11 years ago
In wp_get_installed_translations, the regex [A-Za-z_]{2,6} for detecting the locale seems a bit restrictive. In my plugin dev, I encountered an issue with this rule with German for which two languages packs are distributed: de_DE as standard and de_DE_Sie for the formal language. See http://wpde.org/download/sprachdateien/ . I am not aware of any other exception.
#75
in reply to:
↑ 74
@
11 years ago
Replying to Chouby:
In wp_get_installed_translations, the regex [A-Za-z_]{2,6} for detecting the locale seems a bit restrictive. In my plugin dev, I encountered an issue with this rule with German for which two languages packs are distributed: de_DE as standard and de_DE_Sie for the formal language. See http://wpde.org/download/sprachdateien/ . I am not aware of any other exception.
As far as I can tell, this is extremely wrong. However, we could potentially drop the 6
there, and just match anything. As long as they are only using underscores as delimiters, we should be okay, as a domain that matches a WP.org plugin or theme slug (and ideally any plugin or theme) will always use hyphens.
#77
follow-up:
↓ 81
@
11 years ago
Some questions:
1) I updated one English plugin and there were also automatic language updates/installs of all default themes? I did not want to update/download languages for themes. And it was development SVN repository and I did not expected language downloads. Please do not run language downloads when user does not want (and expect) it.
2) So, every user can update language from GlotPress at any time? And what about when translation will be work in progress? There will be many different versions of translation? There should be any tool (checkbox) for validators to enable project as downloadable for language packs. Or it will be mess. I will validate one day 50 % strings for Twenty Fourteen and many users will download this translation. There will be many support questions "Why is this in English?" Next day I will validate next 20 % strings and all users should redownload? Or language update will run automatically?
#78
@
11 years ago
I think the first point wouldn't be much of an issue. The regular user doesn't know what he expects or wants. So updating languages at the point is fine.
Also the second thing wouldn't be much of an issue I guess. There should be a threshold for sure like 80% need to be translated. Also for the themes it will not be much of an issue since they will be translated during development. So if you using the theme during development then you do ask for it.
#79
@
11 years ago
Ad 1) It is a serious issue, I guess. For example I do not want to use localized version of any plugin/theme. Yes, I can delete it now, but it will be back during several hours? It will be annoying for many users... And what about when I use my own localization edited for special purposes?
Ad 2) Automatic threshold is not a good idea, it should depend on validators. Sometimes can be only 30 % translated (for example only frontend) and it should be delivered to users. And sometimes there are 80 % translated strings and localization is not completed for users. Please, do not use fully automatic approach...
#80
@
11 years ago
1) isn't an issue then since it should not download localized versions when you don't have any. The one that it would overwrite your own version will be an issue. That said you should never willing to do so.
2) Even a validator can't really do something about it. Most people translate strings and validate them without knowing where it is used in the plugin/theme. So the only good way is a treshhold or it only get downloaded when all strings are translated since only then it's completed.
#81
in reply to:
↑ 77
@
11 years ago
Replying to pavelevap:
Some questions:
1) I updated one English plugin and there were also automatic language updates/installs of all default themes? I did not want to update/download languages for themes. And it was development SVN repository and I did not expected language downloads. Please do not run language downloads when user does not want (and expect) it.
I know some people who really need this, anyway I think they are 20% or maybe less. so we can make a plugin to manage the Langauge Packs downloads.
2) So, every user can update language from GlotPress at any time? And what about when translation will be work in progress? There will be many different versions of translation? There should be any tool (checkbox) for validators to enable project as downloadable for language packs. Or it will be mess. I will validate one day 50 % strings for Twenty Fourteen and many users will download this translation. There will be many support questions "Why is this in English?" Next day I will validate next 20 % strings and all users should redownload? Or language update will run automatically?
1+
#82
@
11 years ago
Ad 1) No, it is a serious issue. Examples:
a) I have my own language file cs_CZ.mo in theme directory (or using filter for textdomain). But Updater installs its own theme-cs_CZ.mo file in wp-content/languages/themes directory. This file is not used then, but I do not want this file on my server.
b) There is a plugin which somebody translated and validated with the help of automatic translator and it is not possible to use it on production website. I want to use this plugin in original language, but it is not possible by default. I have to use translated version or use some (not existing now) plugin.
Yes, plugin for managing translations would be helpfull, but I am not sure why should I use plugin for things which are broken by WordPress?
Ad 2) No, treshold is really not a good idea. I am maintaining Czech localization for many years. Everytime I am looking for context because much more better is original English than wrong and messy translations.
Example: I will work on Twenty Fourteen localization and there will be 80 % ready. Then I will be offline for two days. Then I will decide to make some important changes. But there will be many people with older (and wrong) language versions. Validators should have at least checkbox for enabling particular project for downloads. Validators are usually experienced people and there is no need to use automatic treshold to replace their opinion. Or should I translate offline with Poedit and only import final translation? It is against collaborative idea of GlotPress, but I do not want to use not completed translation...
Or Upgrader will automatically check downloaded language files everytime and update them if there will be any change in GlotPress?
#83
follow-up:
↓ 85
@
11 years ago
You mixing point 1 into something different or it wasn't fully explained in the beginning.
Changing plugin files means when you updating them they will be overwritten. That is the same case with language files. If you don't want that then you need to build a plugin thats prevents that. I'm unsure if a md5 hash can help with that.
Not sure what you mean with 1b.
The checkbox would most likely not going to work too. It will be on by default and a few people really going to care about it. And I'm unsure if validators are experienced people. I'm sure you are and I know from a few other languages that they are really strict too but I also know where things get really fast done. What means no checking on context and where it will be used.
#84
@
11 years ago
Yes, maybe, I am still testing and thinking, sorry...
Ad 1a) Yes, but many people know about it now. They use theme, make own edits, own translations and do not care about future updates (actually they will never happen). Instead of md5 hash we could check if there is any other translation loaded (outside wp-content/languages) before downloading language files?
Ad 1b) I do not want to use validated translation with low quality, but original English version.
Ad 2) Checkbox would work for people who want to use it. When I know that translation will be ready in several days, I can turn it off until it is done. It is not a big deal, I guess? Or it can be off by default to make people care about it. Now we can wait for completion and release translation with "big blue button" when needed. It should stay as it is, I hope people are still better then machines :-)
#85
in reply to:
↑ 83
@
11 years ago
Replying to markoheijnen:
The checkbox would most likely not going to work too. It will be on by default and a few people really going to care about it. And I'm unsure if validators are experienced people. I'm sure you are and I know from a few other languages that they are really strict too but I also know where things get really fast done. What means no checking on context and where it will be used.
I suggest to add a select option for validators to enable project as
- "Ready When 100%" (default)
Means that the Language Packs should download the translations if they are 100% only.
- "Ready"
I think it will helpful.. because not all the translations are 100% and it should be an ability to ignore that, since anyone can download it directly from the GlotPress!
- "Not Ready"
In the other side it should be an ability to avoid the auto-downloads even if the translations are 100%... I need this! for example when we finish the first-draft translations we spent more time to double-check the Grammar,Syntax,"Tashkeel"...etc
#87
@
11 years ago
When updating a plugin and translation files are updated too, the action links can be hard to find, see http://cl.ly/RlBq.
#88
follow-up:
↓ 89
@
11 years ago
When making an update, languages files are *all* automatically updated at the latest revision (clearly visible in the picture of @ocean90). Which means, for example, that the user might for some reason keep an old theme or plugin (let say Twenty Ten 1.5), but Twenty Ten languages files are updated to 1.6. If some string has changed or has been removed in the latest revision, it won't be translated anymore.
#89
in reply to:
↑ 88
;
follow-up:
↓ 90
@
11 years ago
Replying to Chouby:
When making an update, languages files are *all* automatically updated at the latest revision (clearly visible in the picture of @ocean90). Which means, for example, that the user might for some reason keep an old theme or plugin (let say Twenty Ten 1.5), but Twenty Ten languages files are updated to 1.6. If some string has changed or has been removed in the latest revision, it won't be translated anymore.
Thankfully, it's a bit smarter than that. :-) The version of the plugin is also considered. If Twenty Ten 1.5 is installed, only a translation designed for 1.5 (or earlier) would be installed. Try installing Twenty Ten 1.5 — you won't get a language pack installed. But if you update to Twenty Ten 1.6, you'll immediately get a pack.
#90
in reply to:
↑ 89
;
follow-up:
↓ 91
@
11 years ago
Replying to nacin:
Thankfully, it's a bit smarter than that. :-) The version of the plugin is also considered. If Twenty Ten 1.5 is installed, only a translation designed for 1.5 (or earlier) would be installed. Try installing Twenty Ten 1.5 — you won't get a language pack installed. But if you update to Twenty Ten 1.6, you'll immediately get a pack.
When I made the initial test, I just asked for a core update and did not notice that the theme was automatically updated to 1.6 (even if I did not want). Note that other (non-default) themes were not updated. So in some way you are right, the language pack matched the theme version. But not exactly the way you are describing. Just because in that case auto upgrade was acting
I tried with:
define('AUTOMATIC_UPDATER_DISABLED', true);
in wp-config.php but that did not avoid theme update as the same time as core.
I modified permissions of the theme directory to disallow theme update (but kept my languages directory writeable). And now as described above, I have unmatching themes and translations. I recognize that it's far-fetched and I got an 'update failed' message so I would not be surprised if something would be wrong late. But so far, I don't know how to avoid theme update at the same time as core to make the test as you described.
#91
in reply to:
↑ 90
@
11 years ago
Replying to Chouby:
When I made the initial test, I just asked for a core update and did not notice that the theme was automatically updated to 1.6 (even if I did not want). Note that other (non-default) themes were not updated. So in some way you are right, the language pack matched the theme version. But not exactly the way you are describing.
What you're running into here, is that Development version upgrades (Automatic, or Manual) will always re-install default themes and plugins, This is because development users get trunk snapshots.
Stable Releases (ie. 3.6, and 3.7 final) are a bit different, a core upgrade does NOT upgrade a bundled Theme, so upgrading core doesn't result in the new theme (& language files) updating as well.
#95
@
11 years ago
- Resolution set to fixed
- Status changed from accepted to closed
I suggest to add a select option for validators
All of this will be handled on the WordPress.org side in the coming weeks.
And with that, this ticket is done. New tickets please for any issues that crop up. Please let me know if I've missed anything spelled out here.
I'll note that one of dimadin's potential future improvements was "On unistallation of plugin/theme, associate language files should be deleted too." This is a mess, see 18200.3.diff. Essentially, we're not going to act on this for now. (If someone wanted to create a ticket, they could.) If we wanted to, we could clear up unused language files on a future update, so it isn't a pressing issue right now.
#99
@
11 years ago
[25818] introduced this line of code -
$upgrade = ! empty( $item->autoupdate );;
Assuming the double semi-colon was unintentional?
#104
follow-ups:
↓ 105
↓ 107
@
11 years ago
Is there a page somewhere that describes how to implement this functionality in a plugin?
#105
in reply to:
↑ 104
;
follow-up:
↓ 106
@
11 years ago
Replying to coolmann:
Is there a page somewhere that describes how to implement this functionality in a plugin?
#106
in reply to:
↑ 105
@
11 years ago
Replying to Ipstenu:
Thank you. However that page doesn't explain how/where to upload all the language files on WordPress.org or glotpress.
#107
in reply to:
↑ 104
@
11 years ago
Replying to coolmann:
Is there a page somewhere that describes how to implement this functionality in a plugin?
Only WordPress.org-owned plugins can currently use this functionality.
It's due to be rolled out to all WordPress.org-hosted plugins when the functionality is available - We don't currently have a way to upload the translations or import them to a WordPress.org-hosted glotpress install.
Unfortunately it's taken much longer than expected for the WordPress.org infrastructure to get finished, there'll be an update here (and the plugins blog at least) when it's available.
#109
@
11 years ago
Thank you, guys. This will be a great functionality and it will save petabytes of data around the world! :)
Two files are currently hard-coded and committed into SVN by translators: setup-config.php, and wp-config-sample.php.
18200.diff implements WP_I18N in setup-config.php. It does not yet touch the default constant values, which must match wp-config-sample.php (and code exists on WP.org to verify this).
The goal would be for these strings to be implemented directly into GlotPress and for wp-config-sample.php to then be filled out in Rosetta. (Rosetta is the code and associated tools that power the local language sites, such as http://pt.wordpress.org/.) This will then remove the SVN requirement for nearly all core packages. (I haven't gotten into $locale.php or special plugins yet, but we will.)