Whilst small files can be uploaded to forum posts, if you have a custom theme or module to contribute please add it on the "Add-ons" page.

TOPIC: [SOLVED] New module plural translation

New module plural translation 3 months 6 days ago #1

  • vytux
  • vytux's Avatar
  • Offline
  • Senior
  • Posts: 456
In the new system there is an example of PLURAL translations, however I am unsure of how to convert non-english versions of plural systems

How do I convert English system such as this
'%s individual' . I18N::PLURAL . '%s individuals' => '%s fish' . I18N::PLURAL . '%s fishes',

into this system (taken from lt.mo)

msgid "%2$s has %1$d first cousin recorded"
msgid_plural "%2$s has %1$d first cousins recorded"
msgstr[0] "%2$s turi %1$d įrašyta pirmos eilės pusbrolį/pusseserę"
msgstr[1] "%2$s turi %1$d įrašytus pirmos eilės pusbrolius/pusseseres"
msgstr[2] "%2$s turi %1$d įrašytų pirmos eilės pusbrolių/pusseserių"
Vytautas

webtrees 1.7.9 (MODS: vytux_cousins, vytux_gallery3, vytux_pages, fancy_imagebar, fancy_treeview, Ancestral fan chart)
PHP 7.1.2, MySQL 5.7.17 x86_64 GPL, Nginx (mainline)
ged.vytux.com
Help translate Vytux Modules at translate.vytux.com/
The administrator has disabled public write access.

New module plural translation 3 months 6 days ago #2

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Posts: 11118
The left hand side is all the English plurals - joined by I18N::PLURAL.

The right hand side is all the translated plurals - joined by I18N::PLURAL.
There can be 1, 2 or more translated plurals.

So you would use

'%2$s has %1$d first cousin recorded' . I18N::PLURAL .
'%2$s has %1$d first cousins recorded'
=>
'%2$s turi %1$d įrašyta pirmos eilės pusbrolį/pusseserę'  . I18N::PLURAL .
'%2$s turi %1$d įrašytus pirmos eilės pusbrolius/pusseseres'  . I18N::PLURAL .
'%2$s turi %1$d įrašytų pirmos eilės pusbrolių/pusseserių',
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net
Last Edit: 3 months 6 days ago by fisharebest.
The administrator has disabled public write access.

New module plural translation 3 months 6 days ago #3

  • vytux
  • vytux's Avatar
  • Offline
  • Senior
  • Posts: 456
OK, that makes sense. Thank you.
Vytautas

webtrees 1.7.9 (MODS: vytux_cousins, vytux_gallery3, vytux_pages, fancy_imagebar, fancy_treeview, Ancestral fan chart)
PHP 7.1.2, MySQL 5.7.17 x86_64 GPL, Nginx (mainline)
ged.vytux.com
Help translate Vytux Modules at translate.vytux.com/
The administrator has disabled public write access.

New module plural translation 3 months 6 days ago #4

  • vytux
  • vytux's Avatar
  • Offline
  • Senior
  • Posts: 456
So I have this in the module and the non-plural translations are NOT working:
protected function lithuanianTranslations(): array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Pusbroliai / Pusseserės',
            'A tab showing cousins of an individual.' => 'Lapas rodantis asmens pusbrolius ir pusseseres.',
            'No family available' => 'Šeima nerata',
            'Father\'s family (%s)' => 'Tėvo šeima (%s)',
            'Mother\'s family (%s)' => 'Motinos šeima (%s)',
            '%2$s has %1$d first cousin recorded' . I18N::PLURAL . '%2$s has %1$d first cousins recorded'   => '%2$s turi %1$d įrašyta pirmos eilės pusbrolį/pusseserę'  . I18N::PLURAL . '%2$s turi %1$d įrašytus pirmos eilės pusbrolius/pusseseres'  . I18N::PLURAL . '%2$s turi %1$d įrašytų pirmos eilės pusbrolių/pusseserių',
        ];
    }
Attachments:
Vytautas

webtrees 1.7.9 (MODS: vytux_cousins, vytux_gallery3, vytux_pages, fancy_imagebar, fancy_treeview, Ancestral fan chart)
PHP 7.1.2, MySQL 5.7.17 x86_64 GPL, Nginx (mainline)
ged.vytux.com
Help translate Vytux Modules at translate.vytux.com/
Last Edit: 3 months 1 day ago by vytux. Reason: Fix sentence logic
The administrator has disabled public write access.

New module plural translation 2 months 3 weeks ago #5

  • vytux
  • vytux's Avatar
  • Offline
  • Senior
  • Posts: 456
The PHP method is still not working, however if you load an MO file it does work as can be seen here.

LT language is via PHP and NL is via MO





/**
     * Additional/updated translations.
     *
     * @param string $language
     *
     * @return string[]
     */
    public function customTranslations(string $language): array
    {
        // Here we are using an array for translations.
        // If you had .MO files, you could use them with:
        // return (new Translation('path/to/file.mo'))->asArray();
        switch ($language) {
            case 'fr':
            case 'fr-CA':
                return $this->frenchTranslations();
            case 'lt':
                return $this->lithuanianTranslations();
            case 'nl':
                return (new Translation(__DIR__ . '/resources/languages/nl.mo'))->asArray();
            default:
                return [];
        }
    }

    /**
     * @return array
     */
    protected function lithuanianTranslations(): array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Pusbroliai / Pusseserės',
            'A tab showing cousins of an individual.' => 'Lapas rodantis asmens pusbrolius ir pusseseres.',
            'No family available' => 'Šeima nerata',
            'Father\'s family (%s)' => 'Tėvo šeima (%s)',
            'Mother\'s family (%s)' => 'Motinos šeima (%s)',
            '%2$s has %1$d first cousin recorded' . I18N::PLURAL . '%2$s has %1$d first cousins recorded'   => '%2$s turi %1$d įrašyta pirmos eilės pusbrolį/pusseserę'  . I18N::PLURAL . '%2$s turi %1$d įrašytus pirmos eilės pusbrolius/pusseseres'  . I18N::PLURAL . '%2$s turi %1$d įrašytų pirmos eilės pusbrolių/pusseserių',
        ];
    }
Vytautas

webtrees 1.7.9 (MODS: vytux_cousins, vytux_gallery3, vytux_pages, fancy_imagebar, fancy_treeview, Ancestral fan chart)
PHP 7.1.2, MySQL 5.7.17 x86_64 GPL, Nginx (mainline)
ged.vytux.com
Help translate Vytux Modules at translate.vytux.com/
The administrator has disabled public write access.

[SOLVED] New module plural translation 2 months 2 weeks ago #6

  • vytux
  • vytux's Avatar
  • Offline
  • Senior
  • Posts: 456
Problem solved.
Vytautas

webtrees 1.7.9 (MODS: vytux_cousins, vytux_gallery3, vytux_pages, fancy_imagebar, fancy_treeview, Ancestral fan chart)
PHP 7.1.2, MySQL 5.7.17 x86_64 GPL, Nginx (mainline)
ged.vytux.com
Help translate Vytux Modules at translate.vytux.com/
The administrator has disabled public write access.
Powered by Kunena Forum