Internationalizations

 

O PmWiki suporta a internacionalização de páginas web, permitindo que caracteres acentuados apareçma em nomes de página e a quese completa customização dos prompts e mensagens do pmwiki. Grande parte da customização é fornecida pela função XL Page() no PmWiki, que carrega um conjunto de variáveis de tradução de uma página wiki (tipicamente nomeada XL Page, mas pode ter qualquer nome que você desejar).

O resto desa página é devotada à instalação, configuração e uso de outros idiomas. Se você está procurando por ferramentas e ajuda para localização do PmWiki na sua lingua, ou como você pode melhorar traduções existentes, comece em pmwiki.org com a página Localization - O portal de tradução.

Carregando páginas de tradução

Muitas páginas em Outras Linguas já foram criadas e mantidas no site pmwiki.org. Você pode baixar um arquivo com essas traduções do endereço http://www.pmwiki.org/pub/pmwiki/i18n/ . Simplismente faça o download dos arquivos de linguagens aprorpiados, e desempacote-os no diretório contendo o arquivo pmwiki.php da sua instalação. Cada arquivo contém um número de arquivos de página que serão colocados dentro do diretório wikilib.d/, e alguns scripts especiais para a tradução que usam um a character set outro que não o iso-8859–1 (padrão do PmWiki). Você também pode usar o charset UTF-8?.

Uma vez que as páginas de tradução estejam instaladas, você habilita uma linguagem adicionando uma chamada para o ⚠ `XLPage() no seu arquivo config.php. Por exemplo, para selecionar prompts em francês, você deve especificar

XLPage('fr','PmWikiFr.XLPage');

Que diz para carregar as traduções para o francês (‘fr’) da página PmWikiFr.XLPage?. É perfeitamente normal carregar multiplas páginas; assim, se você quer criar suas próprias traduções sem mudar as que você tem no arquivo i18n, simplesmente crie uma nova página (veja abaixo) e carregue-a no topo. certifique-se de carregar primeiro a página com as suas mudanças locais:

XLPage('fr','PmWikiFr.XLPageLocal');  # minhas traduções locais 
XLPage('fr','PmWikiFr.XLPage');       # do pacote i18n.tgz

Se a sua intenção é oferecer múltiplas linguagens no seu site, e usar Grupo como seletores de linguagem, você talvez queira colocar este código no seu arquivo de customizações por grupo (veja Group Customizations?). Por exemplo, se o seu site está publicado em Francês e Inglês, e as páginas em francês estão no grupo chamado Fr, você poderia criar um arquivo nomeado como Fr.php no seu diretório local/ , contendo:

<?php if (!defined('PmWiki')) exit();
## mude para o francês
XLPage('fr','PmWikiFr.XLPage');

You may wish to create a page called Pmwiki Fr?.php with the same content to access the French documentation in the Pmwiki Fr? group. En.php is not necessary in this case since English is the default language.

An alternative to the above would be to add to config.php the following, which tests if there is an XL Page in a group, and if it finds one it gets loaded:

    
$xlpage = FmtPageName('$Group.XLPage', $pagename);
if (PageExists($xlpage)) XLPage($xlpage, $xlpage);

With this method you would need to copy any relevant XL Page into any group which needs the different language support.

See also Cookbook:MultiLanguage

Creating New Translations

If language pages don’t exist for your desired language, it’s easy to create one! An XL Page translation file simply contains lines of the form

'phrase' => 'translated phrase',

where “phrase” is an internationalized phrase (denoted by $[phrase]) in PmWiki’s $…Fmt variables, and “translated phrase” is what should be printed in your particular language. For example, the line (in PmWikiFr.XLPage)

'Search' => 'Rechercher',

converts “$[Search]” to “Rechercher” on output. The file Localization:XLPageTemplate is a good starting point for creating a new XL Page and has most of PmWiki’s key phrases already listed in it.

If you create new versions of PmWiki pages in other languages, please consider adding them to the main PmWiki site so that they can be made available to others in the i18n archives! (Be sure to check out The Localization Portal? for further information on effectively internationalizing PmWiki.)

The term “i18n” is commonly used as an abbreviation for the English word “internationalization”. The abbreviation is derived from the fact that there are 18 letters between the “i” and the final “n” and few people want to type them all out.

Enabling “Special” Characters in Wiki Links?

To enable “special” characters like for example German umlauts in Wiki Links?, it is necessary to configure the server locale to ensure that PmWiki uses the proper character set definition.

If this is not possible due to limited access to the server configuration, PmWiki can be configured to use a specific locale by using the XL Page options (see XLPageTemplate).

For German umlauts, you’d need for example:

Note that the locale identifier depends on the operation system and perhaps on the specific installation.

Notes

Q If my wiki is internationalized by config.php, how do I revert a specific group to English?

Use $XLLangs = array('en'); in the group’s group customization? file.

Q If my wiki is in English and I want just one page, or group, in Spanish do I say XLPage('es','PmWikiEs.XLPage'); in the group or page configuration file?

Yes, that is usually the best method. If you were doing this with many scattered pages, or with several languages, you might find it easier to maintain if you load the translations all in config.php like this:

  XL Page(‘es’,’PmWiki Es.XL Page?’);
  XL Page(‘fr’,’PmWiki Fr.XL Page?’);
  XL Page(‘ru’,’PmWiki Ru.XL Page?’);
  $XLLangs = array(‘en’);

Then in each group or page configuration file, you’d just use $XLLangs = array(‘es’); to set the language to use (in this case, Spanish). Note that though this method is easier to maintain, its somewhat slower because it loads all the dictionaries for each page view, even if they won’t be used.

Q What does the first parameter of this function stand for? How can it be used?

The XL Page mechanism allows multiple sets of translations to be loaded, and the first parameter is used to distinguish them.

For example, suppose I want to have translations for both normal French and “Canadian” French. Rather than maintain two entirely separate sets of pages, I could do:

   XL Page(‘fr’, ‘PmWiki Fr.XL Page?’);
   XL Page(‘fr-ca’, ‘PmWiki Fr Ca.XL Page?’);

PmWiki Fr.XL Page? would contain all of the standard French translations, while PmWiki Fr CA.XL Page? would only need to contain “Canada-specific” translations — i.e., those that are different from the ones in the French page.

The first parameter distinguishes the two sets of translations. In addition, a config.php script can use the $XLLangs variable to adjust the order of translation, so if there was a group or page where I only wanted the standard French translation, I can set

   $XLLangs = array(‘fr’, ‘en’);

and PmWiki will use only the ‘fr’ and ‘en’ translations (in that order), no matter how many translations have been loaded with XL Page().

Q How can I use PHP to add a translation for an individual string on the fly?

Use the XLSDV() function to provide a translation for a specific (English) string. For instance, with this in config.php

   XLSDV(‘nl’, array(‘my English expression’=>’mijn Nederlandse uitdrukking’));

any instance of the variable expression $[my English expression] in wiki mark-up will be displayed as my English expression in default (English) context, but as mijn Nederlandse uitdrukking in Dutch (nl) context, i.e. when XLPage('nl',...) has been called for that page in config.php or a cookbook recipe.

But beware: XL Page() uses XLSDV() internally for its translation pairs, too, and only the first definition is accepted! Thus, if the Dutch XL Page already contains a translation for your string like

   ‘my English expression’ => ‘bla bla’,

and you want to override that, you need to use your XLSDV(‘nl’,…) before calling the correspondent XL Page(‘nl’,…). Otherwise, by using XLSDV() after XL Page() - e.g. within a recipe that is included later in config.php - your translation will only work as long nobody defines ‘my English expression’ in that XL Page.


Essa é possivelmente a tradução do original em : PmWiki.Internationalizations - Links de retorno
Essa tradução se encontra em : PmWikiPtBr.Internationalizations - Links de retorno
Últimas modificações da tradução feitas em : 06 de janeiro de 2012, às 15h16
Últimas modificações feitas no original em : 16 de julho de 2022, às 03h49

Pagina modificada em 06 de janeiro de 2012, às 15h16