KWeb  6.4
Strings (translations)

How to automate translations?

There is a command line utility, which helps in translations automation.

It's called strings2po.php and it sits in /kweb/dev/translation/strings2po.php

Its main purpose is to synchronize/copy translation strings between internal string tables and PO files. PO files are used only to ease translation, and are not directly used by the system.

PO files can be used to detect missing translations, and to scan source file for new and obsolete strings.

There are two types of translations:

Indirect translations are there, to ease development for sites that don't need translations, but might need it in the future. By scanning for indirect strings one can translate them later and replace all indirect strings with direct ones by using a tool (

Both translation types use different files. Direct uses source-lang.po (kweb-en.po), and indirect use source-__LANG.po (kweb-__PL.po).

 Usage of strings2po:
        strings2po [-sources=kweb] -po=o -strings=a [-fill -translate=pl]
                either -po or -strings are required
                -sources - catalog with sources (directory containing 'strings' defined in FileDiscovery) like kweb, or local
                -po - store PO files in 'out-sources'. Options are:
                        o - overwrite data with strings or translations (doesn't delete!)
                        a - append missing data from strings or translations
                        s - just save after parsing and sorting
      r - just reads the file
                -strings - store Strings files in 'out-sources'. Same options as in -po
                -fill - fill missing identifiers
                -translate - Language to translate back from, using 'sources-__TRANSLATE.po' file.
                        For '-translate=pl' kweb-__PL.po will be used. 
      All translated strings will be flipped - e.g. polish ids will become strings, and
                        their english translations will become ids.
    -apply - applies changes from out-source

Typicall workflow goes as follows:

  1. Update PO files with data from strings (if necessary):
     php strings2po.php -po=o -fill -apply
    
  2. Open PO files with POEdit. Translate all missing content, especially keyword based.
  3. If you've translated anything, store it in strings:
     php strings2po.php -strings=o -apply
    
  4. Go back to PO files. Scan the sources for additions. Don't care about deleted translations, that weren't marked in the source code. Translate new content.
  5. Again, store it in strings, but also recreate translations deleted from po files:
     php strings2po.php -strings=o -po=a -apply
    
  6. Open indirect files (kweb-__PL.po) and scan sources for changes. translate all new content
  7. Store newly created indirect translations both in strings and in PO files:
     php strings2po.php -po=a -strings=a -translate=pl -apply