GlotPress / GlotPress

:earth_africa: :earth_americas: :earth_asia: GlotPress is a WordPress plugin to let you set up your own collaborative, web-based software translation tool.
https://wordpress.org/plugins/glotpress/
GNU General Public License v2.0
338 stars 123 forks source link

Add header "Language" to metadata .po #428

Closed yuretzru closed 8 years ago

yuretzru commented 8 years ago

Exported po-files incompatible with some libraries. meta Language needed. You can easy fix it.

file: gp-includes/formats/format_pomo.php

add at line: 20 $po->set_header( 'Language', $locale->lang_code_iso_639_1 );

result:

        $po->set_header( 'Content-Transfer-Encoding', '8bit' );
        $po->set_header( 'Plural-Forms', "nplurals=$locale->nplurals; plural=$locale->plural_expression;" );
        $po->set_header( 'X-Generator', 'GlotPress/' . GP_VERSION );
        $po->set_header( 'Language', $locale->lang_code_iso_639_1 );  // new line !!!

        // force export only current translations
        $filters = array();
ocean90 commented 8 years ago

Thanks for the report @yuretzru!

GNU gettext specification: https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Header-Entry.html

Some locales don't have an ISO 639 1 code but based on https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Language-Codes.html#Language-Codes three letter codes are supported as well.

yuretzru commented 8 years ago

Hi Dominik! You are right, my code is incorrect. But the tag "Language" is very necessary for me :) Culd you add it?

toolstack commented 8 years ago

@yuretzru grab this format_pomo.php and see if it does what you need.

yuretzru commented 8 years ago

Yes!!! Thank you Greg!!!!!