Da mir das immer wieder Probleme macht, hier die Checkliste für die Internationalisierung von php-Projekten:
- php gettext
- Verzeichnisstruktur:
- <projekt>
(z.B.my_project)- <language-directory>
(z.B. „lang”)- <locale>
(z.B. „de_DE”, „en_US” etc.)- LC_MESSAGES
- <domain>.po
- <domain>.mo
(z.B.my_project.po,my_project.mo)
- LC_MESSAGES
- <locale>
- <language-directory>
my_project/lang/de_DE/LC_MESSAGES/my_project.pomy_project/lang/de_DE/LC_MESSAGES/my_project.mo
- <projekt>
- Initialisierung:
setlocale(LC_ALL, <locale>);bindtextdomain(<domain>, <language-directory>);textdomain(<domain>);
- Funktionen:
gettext(<text>)
_(<message>)ngettext(<singular-text>, <plural-text>, <count>)dgettext(<domain>, <text>)
(überschreibt die domain für eine einzelne message)dngettext(<domain>, <singular-text>, <plural-text>, <count>)dcgettext(<domain>,<text>, <category>)
(Category als Konstante: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL)dcngettext(<domain>,<singular-text>, <plural-text>, <count>, <category>)
- Verzeichnisstruktur:
- WordPress
- Child Themes
- Verzeichnisstruktur:
- <projekt>
(z.B.my_project)- <language-directory>
(z.B. „lang”)- <locale>.po
- <locale>.mo
(z.B.de_DE.po,de_DE.mo)
- <language-directory>
my_project/lang/de_DE.pomy_project/lang/de_DE.mo
- <projekt>
- Initialisierung:
function load_td() {
load_child_theme_textdomain( <domain>, get_theme_file_path( <language-directory> ) );
}
add_action( 'init', 'load_td' );
- Verzeichnisstruktur:
- Plugins:
- Verzeichnisstruktur:
- <projekt>
(z.B.my_project)- language-directory>
(z.B. „lang”)- <projekt>-<locale>.po
(z.B.my_project/lang/my_project-de_DE.po) - <projekt>-<locale>.mo
(z.B.my_project/lang/my_project-de_DE.mo)
- <projekt>-<locale>.po
- language-directory>
- <projekt>
- Initialisierung:
function load_td() {
load_plugin_textdomain( 'obrama', false, get_template_directory() . '/lang' );
}
add_action( 'init', 'load_td' );- Funktionen:
__(<message>, <domain>)
(gibt übersetzten text zurück)_e(<message>, <function>)
(gibt übersetzten text aus)_x(<text>, <context>, <domain>)
(context als string)_n(<singular-text>, <plural-text>, <count>, <domain>)_nx(<singular-text>, <plural-text>, <count>, <context>, <domain>)
- Verzeichnisstruktur:
- Child Themes