How to use GlotPress for your translations

From the first day I started using GlotPress for translating WordPress into Dutch and Frisian, I fell in love with how GlotPress facilitates the actual process of translating. Before GlotPress I relied on PoEdit, but I felt very little love for how PoEdit worked. GlotPress on the other hand, as a webtool, makes translating software as/with a team an actual possibility. For this very reason alone I installed my own installation about a year ago.

GlotPress is based on BackPress, but it is still in early stages of development. Stable enough to provide us with a platform for teams to translate, but it’s certainly not a finished product. As a translation expert / moderator on the StudioPress forums I installed a GlotPress installation for translating Genesis,  and when Joost de Valk from Yoast.com mentioned to me he was working on making his WordPress SEO Plugin fully translated,  I suggested to him he’d start using GlotPress as well. A few moments later I had installed Joost a GlotPress installation for Yoast.com.

So, on to the topic at hand. How to use GlotPress for your translations. Follow the following steps and you should be good to go.

Installing GlotPress

If you know how to install WordPress then you know how to install GlotPress. The exception being that GlotPress doesn’t have a fancy installer. You need to find the latest version of GlotPress on in SVN trunk. After you have uploaded all the files you need to edit gp-config-sample.php to gp-config.php and edit the database data. Upload it back to your GlotPress folder and run the installation script by visiting the site url. The only extra thing you have to do is add a .htaccess file with the following content:

 
# BEGIN GlotPress .
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END GlotPress

Configuring GlotPress

By default GlotPress will allow you to login with username admin and password a, but as you can imagine, this is not the safest solution. Because GlotPress is based on BackPress it does not have a user interface. Fortunately, there is a solution for this. Additionally, since you’re using GlotPress to provide a platform for people to contribute in translating your software, you will also need a way for people to register. We can solve both those issues by creating a sub-folder in which you’ll install a WordPress installation. Mind you, the need to share the same database. Why you ask? Well, when you check the gp-config.php file you have just created you’ll notice that somewhere down the bottom of that file the following code:


/**
 * Custom users and usermate tables for integration with WordPress user system
 *
 * You might want to delet your current permissions, since they will point to different
 * users in the custom table. You can use `php scripts/wipe-permissions.php` for that.
 *
 * If you start with fresh permissions, you can admins via `php scripts/add-admin.php`
 */
// define('CUSTOM_USER_TABLE', 'wp_users');
// define('CUSTOM_USER_META_TABLE', 'wp_usermeta');

All you need to do is uncomment the first define and change to wp_users to whatever database prefix you’ve decided to use for your WordPress installation. This makes GlotPress use the users table of your WordPress installation, and you’ll notice you can log into GlotPress immediately after you’ve uploaded gp-config.php again.

Note, though the default WordPress registration function will work, it’s much cooler to use Gravity Forms and their User Registration plugin to do your registering. That’s what I used for StudioPress‘ and Yoast’s.

Create an admin

You can log in now, but you can’t actually create projects just yet. You need to do one more thing and you’ll need SSH access to your GlotPress installation for that. Log-in via ssh on your server, navigate to the /scripts folder and execute the script via

$ php /add-admin.php

. So if remkusis the username you’re using the script would look like this:

$ php add-admin.php remkus

. This will turn the specified user into the admin. You can now create projects, create sub-projects, translation sets, import .pot files and import existing .po files for current translations.

Create Validators

GlotPress works with admin, validators and translator roles. You’ve already made yourself an admin, and everyone who registered via your WordPress site is automatically made a translator. The only thing left for you to do is upgrade the proper usernames to the validator role. You can do this in the admin menu Permissions per project. This will allow for validators to approve, reject and edit strings. Just the thing you want as you’re not going to be able to understand every single language you’re going to have in there ;)

Tips for creating a solid translation set

Working with GlotPress is very easy. You can simply double click on the string you’d like to translate and either manually translate or see what the Google Translate option does. Either way, you have to make sure that the translations you create use the same code / HTML in the translated version of the strings as the original. As a validotor you can check out the Warnings listing. This will show you all the strings that have errors in them. You will want to remove / edit those first before you start bulk approve strings.

When you create a project in GlotPress you have the option to add a Source file URL. This usually being the SVN repo link. In Joost’s WordPress SEO plugin’s case you’ll end with this link: http://plugins.trac.wordpress.org/browser/wordpress-seo/trunk/%file%#L%line%. By adding this url you add a reference to the translation strings. You can then click on the reference link and see where in the code the translation string is used.

There will be bugs

As you probably have gathered, installing GlotPress is not for you n00bs out there. You need to be familiar with SVN, SSH, PHP to name but a few acronyms :). Also, GlotPress is not a finished product, so there will be bugs. Find one? Please report them to GlotPress trac.

Need more?

If there’s a need for more tips in the shape of a screen-cast, just let me know in the comments.

Comments

  1. says

    Thanks for share! I was looking for some way to change the admin login quite for a while. Why such things still aren’t available :(

  2. says

    Thanks for the tutorial, and for the research behind it, Remkus!

    I’m setting something like this up for myself, and your instructions are pretty straightforward. I should point out, though, that the add-admin.php script is inside of the scripts subdirectory, which you’ll need to know when you run it from the command line.

    Now I just have to figure out a workflow for pulling my latest dev versions from Github….

  3. says

    Thanks for the tutorial, gonna start using this for my plugins/themes translations.

    Just a quick tip for lighttp users, here’s the rewrite rule I used for GlotPress:

    url.rewrite-once = (
            "^/(css|js|images)/(.*)" => "$0",
            "^/(.*.php)" => "$0",
    
            "^(.*)" => "/index.php?$1"
    )
    • says

      We’re gonna release a all new shiny Swedish community portal for WordPress any day now, We’re gonna use GP to make it easier for Swedish users to create translations together for themes and plugins.

      But, creating an admin user creates problems for us as we can’t use cli commands with our host. Is there really no other way to go? Manually in the database? What exactly does the cli command do?

  4. Daniel Haugen says

    How does the download work? I just get to the website directory and I cant download the complete thing from there… Then Ill be have to create copies of all the files, right?

  5. says

    Hey there,

    one little addition to this amazing tutorial – there is an alternative to ssh in your server. You can grant admin right if you are in mysql – just duplicate the one entry and enter your UserID. I did this because I am using my already existing WordPress User Database.

  6. says

    Finally I understood GP and was able to do a successful install. Thanks for sharing :)

    Are you aware of other resources/plugins?
    I found this and it’s quite nice to get the gist of a GP plugin: https://github.com/GautamGupta/GlotPress-Plugins

    Am wondering about joining both login sessions, so once logged into WP you’re automatically logged into GP. Any hints?

    i installed it on localhost and didn’t have to go through the “Add admin” step.
    @Manuel, just for the records, what exact entry are you mentioning?

  7. Hồ Tuấn Kiệt says

    I get this:
    Warning: require_once(/home/vol12/byethost31.com/b31_13280693/tuankiet-gp.byethost31.com/htdocs/gp-includes/backpress/class.bp-log.php) [function.require-once]: failed to open stream: No such file or directory in /home/vol12/byethost31.com/b31_13280693/tuankiet-gp.byethost31.com/htdocs/gp-settings.php on line 64

  8. says

    Great post ! I already building my own plugin for WordPress, and this is the coolest solution for my plugin translation.

    Side question : Currently I am using the PoEdit to extract my strings for translation, but also extracts and the strings of some sub-folders that are not part of the of the retail plugin version. These folders are part only of the production state. So, can I exclude these folders ? I know that this is not the correct place to ask this question, but I will appriciate if somebody know the answer :)

  9. Ap.Muthu says

    Needs a projects folder and needs gp-includes/backpress folder with backpress in it – http://backpress.org/ – since it refers to the “BP_Log” class in it.

    Also there is no indication of file and folder structure for the pot, po and mo files to go into.

  10. Ap.Muthu says

    gp-settings.php line 64:
    require_once( BACKPRESS_PATH . ‘class.bp-log.php’ );

    the required file has the BP_Log class

  11. says

    (maybe point me to a place for asking user question about glottpress?)

    Is there a chance to have some thing like a child-translation, like child-theme in WordPress?
    We have English as the root language and there are seeral different German translations.
    German formal (100% translated)
    German informal (25% different from formal )

    The best user experience for German-informal users would be to present German formal if there is no translation.

    can a language inherit from an others than the root language?

    • says

      I don’t think child-like translations are the solutions, but I believe it’s actually already possible to have a formal and informal version of any language. You can head over to WordPress Polyglots and post the question.

  12. says

    Hello,
    My wordpress website is reside in subdomain news.mysite.com
    - I have downloaded the latest version of GlotPress.
    - Created .htaccess file with content mentioned above.
    - Renamed gp-config-sample.php to gp-config.php.
    - Changed database name (same database which is used by my wordpress).
    - Database user and password.
    - Uncommented two special lines in gp-config.php which you have mentioned above.
    Everything is almost done.
    Now tell me where I have to upload all glotpress files in order to proceed with installation?
    Can I upload all files to same folder where my wordpress files are exist?

  13. says

    I uploaded the files on the host. I filled in the gp-config.php with the data for the connection to the database. When you access the link, where I uploaded files. gives me a white page … What can I do here? Thanks nice.

Trackbacks

Care to reply?