Bienvenue, Invité
Nom d'utilisateur : Mot de passe :
  • Page :
  • 1

SUJET :

Module translation problems il y a 2 mois 1 semaine #1

  • olor
  • Portrait de olor Auteur du sujet
  • Hors Ligne
  • Membre junior
  • Membre junior
  • chen guo
  • Messages : 127
I downloaded and installed webtrees vytux-Cousins-master module, after rewriting the Chinese translation, there is a place that is not displayed correctly and can't find the problem. Can you help me see it?
    protected function HansTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => '堂表亲',
            'A tab showing cousins of an individual.' => '显示个人表亲的标签。',
            'No family available' => '没有表亲记录',
            'Father\'s family (%s)' => '父亲的家庭 (%s)',
            'Mother\'s family (%s)' => '母亲的家庭 (%s)',
            'has %1$d first cousin recorded'
                . I18N::PLURAL . 'has %1$d first cousins recorded' => '%2$s 有 %1$d 个第一代堂表亲'
                . I18N::PLURAL . '%2$s 有 %1$d 个第一代堂表亲',
        ];
    }

Other contents are correct, and the title has never been translated. But in other Western languages, the translation result is correct.
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Dernière édition: par olor.

Module translation problems il y a 2 mois 1 semaine #2

  • bertkoor
  • Portrait de bertkoor
  • Hors Ligne
  • Membre platinium
  • Membre platinium
  • Greetings from Utrecht, Holland
  • Messages : 2705
Try with a wildcard instead of "8" which is a variable number.
stamboom.BertKoor.nl runs on webtrees v1.7.13

Connexion ou Créer un compte pour participer à la conversation.

Module translation problems il y a 2 mois 1 semaine #3

  • olor
  • Portrait de olor Auteur du sujet
  • Hors Ligne
  • Membre junior
  • Membre junior
  • chen guo
  • Messages : 127

Try with a wildcard instead of "8" which is a variable number.
I used this code,It has not been executed:
'has %1$d first cousin recorded'
                . I18N::PLURAL . 'has %1$d first cousins recorded' => '%2$s 有 %1$d 个第一代堂表亲'
                . I18N::PLURAL . '%2$s 有 %1$d 个第一代堂表亲',

Connexion ou Créer un compte pour participer à la conversation.

Dernière édition: par olor.

Module translation problems il y a 2 mois 1 semaine #4

  • olor
  • Portrait de olor Auteur du sujet
  • Hors Ligne
  • Membre junior
  • Membre junior
  • chen guo
  • Messages : 127
zupu.ml/tree/chen/individual/X104/chen-h...ytux_cousins-master_

you can login to the website,username:chenjun,pw:bawc1966

Thank you very mach!


For the translation of the title, the translation in other languages is normal, and the Chinese translation is not executed.
/**
     * @return array
     */
    protected function dutchTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Neven en Nichten',
            'A tab showing cousins of an individual.' => 'Tab laat neven en nichten van deze persoon zien.',
            'No family available' => 'Geen familie gevonden',
            'Father\'s family (%s)' => 'Vader\'s familie (%s)',
            'Mother\'s family (%s)' => 'Moeder\'s familie (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s heeft %1$d neef of nicht in de eerste lijn'
                . I18N::PLURAL . '%2$s heeft %1$d neven en nichten in de eerste lijn',
        ];
    }

    /**
     * @return array
     */

	 /**
     * @return array
     */
    protected function HansTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => '堂表亲',
            'A tab showing cousins of an individual.' => '显示个人表亲的标签。',
            'No family available' => '没有表亲记录',
            'Father\'s family (%s)' => '父亲的家庭 (%s)',
            'Mother\'s family (%s)' => '母亲的家庭 (%s)',
            'has %1$d first cousin recorded'
                . I18N::PLURAL . 'has %1$d first cousins recorded' => '%2$s 有 %1$d 个第一代堂表亲记录'
                . I18N::PLURAL . '%2$s 有 %1$d 个堂表亲',
        ];
    }
	 /**
     * @return array
     */
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Dernière édition: par olor.

Module translation problems il y a 2 mois 1 semaine #5

  • fisharebest
  • Portrait de fisharebest
  • Hors Ligne
  • Administrateur
  • Administrateur
  • Messages : 16089

Try with a wildcard instead of "8" which is a variable number.
I used this code,It has not been executed:
'has %1$d first cousin recorded'
                . I18N::PLURAL . 'has %1$d first cousins recorded' => '%2$s 有 %1$d 个第一代堂表亲'
                . I18N::PLURAL . '%2$s 有 %1$d 个第一代堂表亲',

You need to have the same %1$s and %2$s in both the english and the translated string. e.g.

'has %1$d first cousin recorded'
'%2$s has %1$d first cousin recorded'

Tip. Do not use numbers. (%d). Always use strings (%s).
You then convert numbers to strings using I18N::number()

When you do this, numbers will be displayed with puncutation, if necesssary. e.g.

I18N::number(1234) = 1,234
Greg Roach - Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser. - fisharebest.webtrees.net

Connexion ou Créer un compte pour participer à la conversation.

Module translation problems il y a 2 mois 1 semaine #6

  • olor
  • Portrait de olor Auteur du sujet
  • Hors Ligne
  • Membre junior
  • Membre junior
  • chen guo
  • Messages : 127
Yes, I use wildcards in my code, not numbers. The rules are the same as those used in other languages.
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Dernière édition: par olor.

Module translation problems il y a 2 mois 1 semaine #7

  • olor
  • Portrait de olor Auteur du sujet
  • Hors Ligne
  • Membre junior
  • Membre junior
  • chen guo
  • Messages : 127


The tick works normally, and the code of the Red Cross is not executed correctly.
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Module translation problems il y a 2 mois 1 semaine #8

  • bertkoor
  • Portrait de bertkoor
  • Hors Ligne
  • Membre platinium
  • Membre platinium
  • Greetings from Utrecht, Holland
  • Messages : 2705
You have a typo in the sentence. "cousin" should be "cousins".
stamboom.BertKoor.nl runs on webtrees v1.7.13

Connexion ou Créer un compte pour participer à la conversation.

Avez-vous besoin d'une solution d'hébergement web pour votre site webtrees ?
Si vous préférez un hébergeur spécialisé de webtrees, la page suivante en liste quelques-uns capables de vous offrir ce type de service :

Module translation problems il y a 2 mois 1 semaine #9

  • fisharebest
  • Portrait de fisharebest
  • Hors Ligne
  • Administrateur
  • Administrateur
  • Messages : 16089
Your english sentence is wrong. It is missing the %2$s.

It is "has ..."
It should be "%2$s has ..."

The english sentence and the translated sentence must have the same %1$s and %2$s.

It is conventional to number them in order. %1$s is used first. %2$s is used second.
Greg Roach - Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser. - fisharebest.webtrees.net

Connexion ou Créer un compte pour participer à la conversation.

Module translation problems il y a 2 mois 1 semaine #10

  • olor
  • Portrait de olor Auteur du sujet
  • Hors Ligne
  • Membre junior
  • Membre junior
  • chen guo
  • Messages : 127
My code on the website contains (% 2 $s) and (% 1 $d). The English part is consistent with other languages. I only modified the code behind “=>”.
    /**
     * 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 'da':
                return $this->danishTranslations();

            case 'fi':
                return $this->finnishTranslations();

            case 'fr':
            case 'fr-CA':
                return $this->frenchTranslations();

            case 'he':
                return $this->hebrewTranslations();

            case 'lt':
                return $this->lithuanianTranslations();

            case 'nb':
                return $this->norwegianBokmålTranslations();

            case 'nl':
                return $this->dutchTranslations();

            case 'nn':
                return $this->norwegianNynorskTranslations();

            case 'sv':
                return $this->swedishTranslations();

            case 'cs':
                return $this->czechTranslations();

            case 'de':
                return $this->germanTranslations();
				
            case 'zh-Hans':
                return $this->hansTranslations();				
			
            case 'zh-Hant':
                return $this->hantTranslations();
				
            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 nerasta',
            '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ų',
        ];
    }

    /**
     * @return array
     */
    protected function germanTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Cousins und Cousinen',
            'A tab showing cousins of an individual.' => 'Ein Reiter, der Cousins und Cousinen der Person anzeigt.',
            'No family available' => 'Es gibt keine Familie',
            'Father\'s family (%s)' => 'Väterlicherseits (%s)',
            'Mother\'s family (%s)' => 'Mütterlicherseits (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s hat einen Cousin oder eine Cousine ersten Grades'
                . I18N::PLURAL . '%2$s hat %1$d Cousins oder Cousinen ersten Grades',
        ];
    }

    /**
     * @return array
     */
    protected function danishTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Fætre og kusiner',
            'A tab showing cousins of an individual.' => 'En fane der viser en persons fætre og kusiner.',
            'No family available' => 'Ingen familie tilgængelig',
            'Father\'s family (%s)' => 'Fars familie (%s)',
            'Mother\'s family (%s)' => 'Mors familie (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s har %1$d registreret fæter eller kusin'
                . I18N::PLURAL . '%2$s har %1$d registrerede fæter eller kusiner',
        ];
    }

    /**
     * @return array
     */
    protected function frenchTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Cousins',
            'A tab showing cousins of an individual.' => 'Onglet montrant les cousins d\'un individu.',
            'No family available' => 'Pas de famille disponible',
            'Father\'s family (%s)' => 'Famille paternelle (%s)',
            'Mother\'s family (%s)' => 'Famille maternelle (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s a %1$d cousin germain connu'
                . I18N::PLURAL . '%2$s a %1$d cousins germains connus',
        ];
    }

    /**
     * @return array
     */
    protected function finnishTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Serkut',
            'A tab showing cousins of an individual.' => 'Välilehti joka näyttää henkilön serkut.',
            'No family available' => 'Perhe puuttuu',
            'Father\'s family (%s)' => 'Isän perhe (%s)',
            'Mother\'s family (%s)' => 'Äidin perhe (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s:llä on %1$d serkku sivustolla'
                . I18N::PLURAL . '%2$s:lla on %1$d serkkua sivustolla',
        ];
    }

    /**
     * @return array
     */
    protected function hebrewTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'בני דודים',
            'A tab showing cousins of an individual.' => 'חוצץ המראה בני דוד של אדם.',
            'No family available' => 'משפחה חסרה',
            'Father\'s family (%s)' => 'משפחת האב (%s)',
            'Mother\'s family (%s)' => 'משפחת האם (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => 'ל%2$s יש בן דוד אחד מדרגה ראשונה'
                . I18N::PLURAL . 'ל%2$s יש %1$d בני דודים מדרגה ראשונה',
        ];
    }

    /**
     * @return array
     */
    protected function norwegianBokmålTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Søskenbarn',
            'A tab showing cousins of an individual.' => 'Fane som viser en persons søskenbarn.',
            'No family available' => 'Ingen familie tilgjengelig',
            'Father\'s family (%s)' => 'Fars familie (%s)',
            'Mother\'s family (%s)' => 'Mors familie (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s har %1$d registrert søskenbarn'
                . I18N::PLURAL . '%2$s har %1$d registrerte søskenbarn',
        ];
    }

    /**
     * @return array
     */
    protected function norwegianNynorskTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Syskenbarn',
            'A tab showing cousins of an individual.' => 'Fane som syner ein person sine syskenbarn.',
            'No family available' => 'Ingen familie tilgjengeleg',
            'Father\'s family (%s)' => 'Fars familie (%s)',
            'Mother\'s family (%s)' => 'Mors familie (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s har %1$d registrert syskenbarn'
                . I18N::PLURAL . '%2$s har %1$d registrerte syskenbarn',
        ];
    }

    /**
     * @return array
     */
    protected function dutchTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Neven en Nichten',
            'A tab showing cousins of an individual.' => 'Tab laat neven en nichten van deze persoon zien.',
            'No family available' => 'Geen familie gevonden',
            'Father\'s family (%s)' => 'Vader\'s familie (%s)',
            'Mother\'s family (%s)' => 'Moeder\'s familie (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s heeft %1$d neef of nicht in de eerste lijn'
                . I18N::PLURAL . '%2$s heeft %1$d neven en nichten in de eerste lijn',
        ];
    }

    /**
     * @return array
     */
    protected function swedishTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Kusiner',
            'A tab showing cousins of an individual.' => 'En flik som visar en persons kusiner.',
            'No family available' => 'Familj saknas',
            'Father\'s family (%s)' => 'Faderns familj (%s)',
            'Mother\'s family (%s)' => 'Moderns familj (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s har %1$d registrerad kusin'
                . I18N::PLURAL . '%2$s har %1$d registrerade kusiner',
        ];
    }

    /**
     * @return array
     */
    protected function czechTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => 'Bratranci',
            'A tab showing cousins of an individual.' => 'Panel zobrazující bratrance osoby.',
            'No family available' => 'Rodina chybí',
            'Father\'s family (%s)' => 'Otcova rodina (%s)',
            'Mother\'s family (%s)' => 'Matčina rodina (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s má %1$d bratrance'
                . I18N::PLURAL . '%2$s má %1$d bratrance'
                . I18N::PLURAL . '%2$s má %1$d bratranců',
        ];
    }
	
	 /**
     * @return array
     */
    protected function HansTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => '堂表亲',
            'A tab showing cousins of an individual.' => '显示个人表亲的标签。',
            'No family available' => '没有表亲记录',
            'Father\'s family (%s)' => '父亲的家庭 (%s)',
            'Mother\'s family (%s)' => '母亲的家庭 (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s 有 %1$d 个第一代堂表亲记录'
                . I18N::PLURAL . '%2$s 有 %1$d 个第一代堂表亲',
        ];
    }
	 /**
     * @return array
     */
    protected function HantTranslations() : array
    {
        // Note the special characters used in plural and context-sensitive translations.
        return [
            'Cousins' => '堂表亲',
            'A tab showing cousins of an individual.' => '显示个人表亲的标签。',
            'No family available' => '没有表亲记录',
            'Father\'s family (%s)' => '父亲的家庭 (%s)',
            'Mother\'s family (%s)' => '母亲的家庭 (%s)',
            '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s 有%1$d个第一代堂表亲'
                . I18N::PLURAL . '%2$s 有 %1$d 个第一代堂表亲',
        ];
    }

It is very strange that other languages can translate the correct results, and other labels in Chinese functions can also be translated correctly, except for the title with two wildcards, which only replaces the two values of individual and number, and the language has not been translated.

Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Dernière édition: par olor.

Module translation problems il y a 2 mois 1 semaine #11

  • fisharebest
  • Portrait de fisharebest
  • Hors Ligne
  • Administrateur
  • Administrateur
  • Messages : 16089
Did you add
case 'zh-Hans':
                return $this->HantTranslations();
Greg Roach - Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser. - fisharebest.webtrees.net

Connexion ou Créer un compte pour participer à la conversation.

Module translation problems il y a 2 mois 1 semaine #12

  • olor
  • Portrait de olor Auteur du sujet
  • Hors Ligne
  • Membre junior
  • Membre junior
  • chen guo
  • Messages : 127

Did you add
case 'zh-Hans':
                return $this->HantTranslations();

yes,it was in my code.

Connexion ou Créer un compte pour participer à la conversation.

Module translation problems il y a 2 mois 1 semaine #13

I'm confused. There are several pieces of code, but they are not consistent. Please check:
  • "HantTranslations()" versus "hantTranslations()". Lowercase or Uppercase is significant!
  • Check if you are supporting both: zh-Hans and zh-Hant (simplified and traditional), please!
  • if the singular part of the English phrase "'%2$s has %1$d first cousin recorded'" contains the "'%2$s" at the beginning
  • maybe you should add an empty space " " before and after "%1$d" at "%2$s 有%1$d个第一代堂表亲"
Hermann
Designer of the custom module "Extended Family"

webtrees 2.0.23 (all custom modules installed, php 7.4.15, MySQL 5.6) @ ahnen.hartenthaler.eu

Connexion ou Créer un compte pour participer à la conversation.

Module translation problems il y a 2 mois 1 semaine #14

  • olor
  • Portrait de olor Auteur du sujet
  • Hors Ligne
  • Membre junior
  • Membre junior
  • chen guo
  • Messages : 127
I checked character by character, and there was no problem with the code. It is very strange that the same plural translation sentence can be translated into Chinese in Danish function, but not in Chinese function. I'm a little broken.
    protected function danishTranslations() : array
    {
        ...
                 '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s 有 %1$d 个第一代堂表亲'
                . I18N::PLURAL . '%2$s 有 %1$d 个第一代堂表亲些',[/color]
        ];
    }
Execution has a correct result:


In Chinese function:
    protected function hansTranslations() : array
    {
     ...
                 '%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s 有 %1$d 个第一代堂表亲'
                . I18N::PLURAL . '%2$s 有 %1$d 个第一代堂表亲些',[/color]
        ];
    }
Get an incorrect execution result:

The red code in the two functions is the same, but the result is different, isn't it strange?
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Dernière édition: par olor.

Module translation problems il y a 2 mois 1 semaine #15

It may look strange but it isn't. There are different plural rules. Many languages have singular and (one) plural form. Others have singular and two or more plural forms, for example singular for 1, one plural for 2, 3, 4 and another plural for 5 or more than 5 pieces. As far as I know in the Chinese language there is no plural as we know it for example in English or German language.
So, you should try:
'%2$s has %1$d first cousin recorded'
                . I18N::PLURAL . '%2$s has %1$d first cousins recorded' => '%2$s 有 %1$d 个第一代堂表亲',
So English singular and plural are translated to only one Chinese form.

If you like to search for examples you should not use the Danish language that has singular and plural as it is used in the English language. Check translations into Japanese, Korean, Vietnamese, Persian, Turkish, or Thai.
Hermann
Designer of the custom module "Extended Family"

webtrees 2.0.23 (all custom modules installed, php 7.4.15, MySQL 5.6) @ ahnen.hartenthaler.eu

Connexion ou Créer un compte pour participer à la conversation.

Dernière édition: par hermann.

Module translation problems il y a 2 mois 1 semaine #16

  • olor
  • Portrait de olor Auteur du sujet
  • Hors Ligne
  • Membre junior
  • Membre junior
  • chen guo
  • Messages : 127
Really, as you said, two English sentences correspond to one Chinese sentence. Thank you, Hermann. I salute you!

Connexion ou Créer un compte pour participer à la conversation.

  • Page :
  • 1
Propulsé par Kunena