I came across the same problem.
for example i have
in php
//Gives FORM_HEADER_ADD or FORM_HEADER_EDIT
echo $this->translate('FORM_HEADER_' . strtoupper($this->data));
When i sync with poedit it will pick up 'FORM_HEADER_' which is not a identifier i have (generated) in the code.
So i had to fix the problem my giving Poedit full identifiers i solved that by doing the following in php
echo ($this->data === 'add') ? $this->translate('FORM_HEADER_ADD') : $this->translate('FORM_HEADER_EDIT');
UPDATE!
I kept looking into this problem. And i currently gave up importing from source. This is how i continue until i find a better solution
- Build application and use as many static identifiers as possible.
Enable logging of untranslated (dynamic) identifiers
protected function _initMyTranslate(){
$date = new Zend_Date();
$fileName = sprintf('/../logs/translation_%1$s.log', $date->toString('dd-MM'));
$writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . $fileName);
$log = new Zend_Log($writer);
// get the translate resource from the ini file and fire it up
$resource = $this->getPluginResource('translate');
$translate = $resource->getTranslate();
// add the log to the translate
$translate->setOptions(
array(
'log' => $log,
'logUntranslated' => true
)
);
// return the translate to get it in the registry and so on
return $translate;
}
Use Poedit to sync with source and translate the strings that are found.
- During testing/debugging phase check the log for untranslated strings.
Add the untranslated strings to the .po file.
msgid "IDENTIFIER"
msgstr "TRANSLATION STRING"
Open po file and save it to create the mo file (DO NOT SYNC WITH SOURCE OR ALL IS LOST).
UPDATE 2.
I now use a seperate file for my manual identifiers , by using a text editor (gedit/notepad). Now i have two files:
- Auto generated by poedit called <language>.po
- manually editted file called <language>_manual.po
i configured my translate in application.ini to scan for all files in the language directory
resources.translate.adapter = gettext
resources.translate.content = APPLICATION_PATH "/../library/languages/"
resources.translate.locale = auto ;use en to force english or nl for dutch..etc
resources.translate.scan = directory
resources.translate.options.disableNotices = false
if you want to translate into another language in poedit do file -> new catalog from POT file, and start translating your manually added strings.