Jean-Francois Paradis

Web Developer + Architect

EE Reword Plugin

| Comments

Reword is a simple plugin for ExpressionEngine inspired from the WordPress functions translate(), __() and _e() which translate a website into another language, depending on the language of the user’s browser, and using a dictionary.

Its basic usage is quite similar to __() so if you are familiar with WordPress, you can use Reword right-away:

  1. Install the plug-in
  2. Provide a dictionary file
  3. Add tags to your templates

Here is a simple dictionary:

1
2
3
4
5
6
7
8
9
<?php
$lang = array(
    'Hello' => 'Bonjour',
    'Hello %s' => 'Bonjour %s',
    '%s search results for "%s"' => '%s résultats pour "%s"',
    '%M %d, %Y' => '%d %M %Y',
    'Posted %d' => "Publié le %d"
);
?>

Here is a sample usage in a template:

1
2
3
4
5
6
7
8
9
10
11
{exp:sk_reword text='Hello'}
// Output: Bonjour

{exp:sk_reword text='Hello %s' string='Mary'}
// Output: Bonjour Mary

{exp:sk_reword text='%s search results for "%s"' string='25|Test'}
// Output: 25 résultats pour "Test"

{exp:sk_reword text='Posted %d' format='%M %d, %Y' date='2012-09-07'}
// Output: Publié le 07 Sep 2012

See the included README file for more information.

You can get the code on GitHub or through Devot-ee.

Comments