Check­lis­te php-Internationalization

Da mir das immer wie­der Pro­ble­me macht, hier die Check­lis­te für die Inter­na­tio­na­li­sie­rung von php-Projekten:

  1. php get­text
    • Ver­zeich­nis­struk­tur:
      • <pro­jekt>
        (z.B. my_project)
        • <lan­guage-direc­to­ry>
          (z.B. „lang”)
          • <loca­le>
            (z.B. „de_DE”, „en_US” etc.)
            • LC_MESSAGES
              • <domain>.po
              • <domain>.mo
                (z.B. my_project.po, my_project.mo)
      • my_project/lang/de_DE/LC_MESSAGES/my_project.po
      • my_project/lang/de_DE/LC_MESSAGES/my_project.mo
    • Initia­li­sie­rung:
      • setlocale(LC_ALL, <locale>);
      • bindtextdomain(<domain>, <language-directory>);
      • textdomain(<domain>);
    • Funk­tio­nen:
      • gettext(<text>)
        _(<message>)
      • ngettext(<sin­gu­lar-text>, <plu­ral-text>, <count>)
      • dgettext(<domain>, <text>)
        (über­schreibt die domain für eine ein­zel­ne message)
      • dngettext(<domain>, <sin­gu­lar-text>, <plu­ral-text>, <count>)
      • dcgettext(<domain>,<text>, <cate­go­ry>)
        (Cate­go­ry als Kon­stan­te: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL)
      • dcngettext(<domain>,<singular-text>, <plu­ral-text>, <count>, <cate­go­ry>)
  2. Word­Press
    • Child The­mes
      • Ver­zeich­nis­struk­tur:
        • <pro­jekt>
          (z.B. my_project)
          • <lan­guage-direc­to­ry>
            (z.B. „lang”)
            • <locale>.po
            • <locale>.mo
              (z.B. de_DE.po, de_DE.mo)
        • my_project/lang/de_DE.po
        • my_project/lang/de_DE.mo
      • Initia­li­sie­rung:
        • function load_td() {
          load_child_theme_textdomain( <domain>, get_theme_file_path( <language-directory> ) );
          }
          add_action( 'init', 'load_td' );
    • Plug­ins:
      • Ver­zeich­nis­struk­tur:
        • <pro­jekt>
          (z.B. my_project)
          • lan­guage-direc­to­ry>
            (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)
      • Initia­li­sie­rung:
        • function load_td() {
          load_plugin_textdomain( 'obrama', false, get_template_directory() . '/lang' );
          }
          add_action( 'init', 'load_td' );
        • Funk­tio­nen:
          • __(<mes­sa­ge>, <domain>)
            (gibt über­setz­ten text zurück)
          • _e(<mes­sa­ge>, <func­tion>)
            (gibt über­setz­ten text aus)
          • _x(<text>, <con­text>, <domain>)
            (con­text als string)
          • _n(<sin­gu­lar-text>, <plu­ral-text>, <count>, <domain>)
          • _nx(<sin­gu­lar-text>, <plu­ral-text>, <count>, <con­text>, <domain>)

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

5 × drei =