i have upgraded my theme to D6 and activated the theme having language files in the folder sites\all\themes\mytheme\translations. After pressing "Save configuration" i get tons of the following errors.

Only one example:

user warning: Data too long for column 'language' at row 1 query: INSERT INTO locales_target (lid, language, translation, plid, plural) VALUES (313, 'all/themes/mytheme/translations/de', 'Zur Navigation springen', 0, 0) in C:\Inetpub\wwwroot\drupal6\includes\locale.inc on line 1285.
CommentFileSizeAuthor
#4 language_code.patch988 bytesGábor Hojtsy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

This looks like your PO file is broken. Can you post the first 30 lines of your de.po file for the theme here?

hass’s picture

I think the bug is caused by all/themes/mytheme/translations/de... and this is not POT file related... The insert is trying to insert a path where it should only insert the language iso code...

Nevertheless, the first 30 lines from the POT:

msgid ""
msgstr ""
"Project-Id-Version: German translation of YAML for Drupal\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2007-09-26 21:41+0100\n"
"Last-Translator: Alexander Hass\n"
"Language-Team: Alexander Hass\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Country: GERMANY\n"
"X-Poedit-SourceCharset: utf-8\n"
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
"X-Poedit-Language: German\n"

#: page.tpl.php:20;20
#: layouts/yaml_1col/page.tpl.php:20;20
#: layouts/yaml_2col_left_13/page.tpl.php:20;20
#: layouts/yaml_2col_right_13/page.tpl.php:20;20
#: layouts/yaml_3col_standard/page.tpl.php:20;20
msgid "Skip to the navigation"
msgstr "Zur Navigation springen"

#: page.tpl.php:21;21
#: layouts/yaml_1col/page.tpl.php:21;21
#: layouts/yaml_2col_left_13/page.tpl.php:21;21
#: layouts/yaml_2col_right_13/page.tpl.php:21;21
#: layouts/yaml_3col_standard/page.tpl.php:21;21
msgid "Skip to the content"
msgstr "Zum Inhalt springen"
Gábor Hojtsy’s picture

Status: Postponed (maintainer needs more info) » Active

Ah, I see. This might have something to do with how the language code is computed there, which looks quite interesting.

Gábor Hojtsy’s picture

Status: Active » Needs review
FileSize
988 bytes

Hm, this is the code which tried to find out the language code from the filename:

function _locale_batch_import($filepath, &$context) {
  include_once 'includes/locale.inc';
  // The filename is either {langcode}.po or {prefix}.{langcode}.po, so
  // we can extract the language code to use for the import from the end.
  if (preg_match('!(/|\.)([^\.]+)\.po$!', $filepath, $langcode)) {
    $file = (object) array('filename' => basename($filepath), 'filepath' => $filepath);
    _locale_import_read_po('db-store', $file, LOCALE_IMPORT_KEEP, $langcode[2]);
    $context['results'][] = $filepath;
  }
}

This matches file path endings like "/de.po" or "something.de.po". Seems like the ([^\.]+) part is a bit too greedy here, and it should also exclude slashes. Please try to use the '!(/|\.)([^\./]+)\.po$!' pattern (so we exclude / from the language code we match against), and report results.

hass’s picture

This patch works for me. All strings successfully imported without any errors :-).

Aside are you able to give me a hint, about the plan for the splitted files for complete translation, please? Is the final plan to create in every modules directory a sub directory "translations" and place the small appropriate files for every language there, or is there any global directory planed, where we drop all splitted files in? I don't like to put 15 files of 10 languages in the website root or the same directory :-(.

Gábor Hojtsy’s picture

Status: Needs review » Fixed

Thanks, patch committed.

The idea of course is that every module would have a translations subfolder with files *for that module* per language. This allows us to only load what's really required, and not load extra stuff, which would be unused and would slow down your site. Example tarball: http://drupal.org/node/176141 Now extractor.php / potx-cli.php generated files can be automatically packaged to this kind of tarballs with po-packager: http://cvs.drupal.org/viewvc.py/drupal/contributions/tricks/po-packager/ Although this is just a dirty trick for now, and there supposed to be a better solution for translators which will autogenerate tarballs in this format. See http://hojtsy.hu/drop/LocalizationServer.swf This is still in the works, but it accessible and possible to try out: http://drupal.org/project/l10n_server A copy of this will be hosted at drupal.org to provide a central collaboration interface for translations.

hass’s picture

COOOOOOL. THX... the po-packager was the thing i'm searching and tried to build myself... i will give it a try.

Anonymous’s picture

Status: Fixed » Closed (fixed)