5

I've already checked http://i18n.svn.wordpress.org/, but something seems off. I need official file checksums.

I took /ar (Arabic) as an example, and compared all the files in the repository against the files that I downloaded from http://ar.wordpress.org/, and they don't match (specifically, wp-content/languages/ar.po and ar.mo files). Also, the /ar/trunk and /ar/tags/4.1 directories are pretty much empty. Am I missing something?

7

i18n resource ... the hide & seek game

Note up front: I'm not 100% sure about this, so please take the following with a grain of salt.

I'm 99% sure by now, that the following information is correct. (Still, it's confusing even after years with WordPress).


Non-Gettext translation for core

The 18n.wordpress.org resource is used by the Glotpress project. There you can find nearly all languages for the files that are not translatable with Gettext and look at the language completion status. This means: wp-config-sample.php, readme.txt, license.txt and some messages, etc. are translated there

Gettext translation for core

When you look at the WordPress APIs page, then you will find the Translation section as well. There you will find not only pointers core, but for all wp.org hosted plugins and themes as well. When you ping

https://api.wordpress.org/translations/core/1.0/?version={wp-version}

you will get back a JSON response (example for WP v4.1.1). Example output (shortened):

{
    "translations" : [ 
        {
            "language"     : "ar",
            "version"      : "4.1.1",
            "updated"      : "2015-01-17 19:01:24",
            "english_name" : "Arabic",
            "native_name"  : "\u0627\u0644\u0639\u0631\u0628\u064a\u0629",
            "package"      : "https:\/\/downloads.wordpress.org\/translation\/core\/4.1.1\/ar.zip",
            "iso"          : {
                "1" : "ar",
                "2" : "ara"
            },
            "strings"      : { 
                "continue" : "\u0627\u0644\u0645\u062a\u0627\u0628\u0639\u0629"
            }
        },
        // ... other languages here

The language and iso will be of the following

The repository contains directories for each locale, which are named as follows:

  • ISO 639 language code (lowercase) or
  • ISO 639 language code (lowercase) + an underscore + ISO 3166-1 alpha-2 country code (uppercase) or
  • ISO 639-3 language code (lowercase)

Quote: Repo file structure on Glotpress - props Dominik "@ocean90" Schilling for fixing this in the GlotPress docs.

The "ISO 639" (and it's used parts 1 & 2) are the international bibliographic language and country codes. @StephenHarris and me are maintaining the "WCM User Language Switcher" with its break out project, the "ISO 639-1/2" JSON source (afaik, there's only this one on the internets) which you can take to verify parts of the JSON return.

Every language code present in the two-letter code set has a corresponding language code in the alpha-3 list, but not necessarily vice versa. ISO 639-2:1998 provides two sets of three-letter alphabetic codes for the representation of names of languages, one for terminology applications and the other for bibliographic applications. The code sets are the same except for twenty-five languages that have variant language codes because of the criteria used for formulating them.

Checksums

There's also an official API endpoint for checksums in your language:

https://api.wordpress.org/core/checksums/1.0/?version={version_number}&locale={iso_code}

Just fill iso_code with de_DE for example.

The returned JSON will look like the following:

{
    "checksums" : {
        "wp-settings.php" : "c4833959e93d9368a35712e52c57c650",
        "wp-cron.php"     : "cf2ae664186202bf6944c31378ec5af9",
        // ...

That's it.

Edit: I just looked at ~/wp-admin/includes/update-core.php and the update_core() version and it seems that we got a global $wp_local_page global as well. There you will as well find the get_core_checksums() function.

Gets and caches the checksums for the given version of WordPress.

@return boolean|array False on failure. An array of checksums on success.

This is how core is using it inside update_core():

$cs = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );

The WordPress version

The WordPress version can be obtained from the $GLOBALS['wp_version']. Make sure that you use a stable version and don't try this on trunk where you will find stuff like '4.2-alpha-31531' while the current version is 4.1.1. Which obviously will return ... nothing.

Issues with the WordPress Internal Updater

One more issue: If you just download translation files as outlined above and in the Codex but not a complete localized package the updater might start bugging you to update even if your files are already up to date. This is due to localized packages setting the global variable $wp_local_package. For more details have a look at this question.

Quick example

To give a more WordPress-y touch to those WordPress structures, just fetch the resources with the WP HTTP API. I wrote plenty of example answers: Link to SERP here. You might want to perform a wp_remote_head() request to check if a file exists before fetching it.

i18n files via ... Composer!

And then - as fellow Austrian @kraftner pointed out - there, on Koodimonni in Finland, you will find a Satis repo updated every 30 minutes. More info when you follow the link. Hint: Prefer this source if you are trying to setup WP. Else prefer the above when building remote requests or plugin stuff yourself.

  • Thanks for this great and detailed post. Does that mean there is no centralized way to access the official localized files only but to extract the official .zip files? The sr_RS (Serbian) localized files for instance are accessible via SVN, which is great, but ar (Arabic) aren't, so I assume those are managed separately. Does that mean that the translation teams themselves build the .zip files? – Gray Fox Feb 25 '15 at 11:18
  • 1
    @GrayFox That means that each translation team builds its own, localized "Non-Gettext" versions and bundles them as *.zip files and delivers them via 18n.svn.wordpress.org. And that means every translation relies on just some people. The .po files still are accessible via api.wordpress.org remote access (JSON), but again come as *.zip file when you request it. – kaiser Feb 25 '15 at 11:22

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.