• Resolved transl8or

    (@transl8or)


    Hello @timwithlock,

    I have just overhauled some of the (german) translations for the Loco Translate plugin.

    There is a string -> One string extracted from source code for “%2$s” <- in the debugger.php, line 186, which has a singular and plural variant.

    Singular:
    One string extracted from source code for “%2$s”

    Plural:
    %s strings extracted from source code for “%s”

    I wonder if the Plural string needs a correction with your next release?

    Shouldn’t it be:
    %s strings extracted from source code for “%2$s”

    or to provide better understandable quote-signs for all translators (because various languages have different prefered quote-signs):
    %s string extracted from source code for “%2$s”

    Just to explain an example:
    In german we translate “ with „ (or: „ — in words: 99 at the bottom ) and ” with “ (or: “ — in words: 66 at the top)
    In spain they have “ as « and ” is »

    The same can be found in your InitPoController.php, line 196. with the string -> One string found in %2$s <-.
    The plural form (or should I better say phraze) is using the variable %s twice. Should it be %s for the number of strings and %2$s for the name of the source code where it is extracted from?

    On another note. I think it would be highly appreciated if you could add a Comment to these singular/plural strings for all translators of the many languages, like it is established in core or many themes.

    Something like:
    1: number of strings
    2: name of source code file

    As I have contributed translations to a lot of themes you may be able to see a coding example in the context of singular/plural variants in many themes in the source code for the comments section. The most common way I’ve come around was something like

    Singular:
    %1$s thought on “%2$s”
    or: One thought on “%2$s” (This is the better variant in german)

    Plural:
    %1$s thoughts on “%2$s”

    Comment:
    1: number of comments
    2: post title

    Just to name some examples.

    Hope you don’t mind my long explanation and can understand what I tried to communicate.

    Thanks a lot for your Plugin.
    Greetings, transl8or (she/her)

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter transl8or

    (@transl8or)

    Plugin Author Tim W

    (@timwhitlock)

    Thanks for your hard work, but I don’t maintain any translations of my plugin. Releases of Loco Translate do not include translation files.

    The community translation projects that you link to belong to WordPress and I am not involved. Please report any problems to the German team, or ask to join them if you wish to contribute.

    Apologies. I skim read this. You are referring to source text. I will review now.

    Thread Starter transl8or

    (@transl8or)

    Yes, I have refered to your source code.

    Another tiny thing: I just saw the http link to http://php.net/manual/en/book.tokenizer.php and it now is forwarded to https.
    The new link in your file no-tokenizer.php, line 17 could probably be:
    https://www.php.net/manual/en/book.tokenizer.php

    Plugin Author Tim W

    (@timwhitlock)

    Shouldn’t it be:
    %s strings extracted from source code for “%2$s”

    In this case they are equivalent. PHP allows positional arguments to be implied by sequence. It is required in the singular because I have chosen to NOT display the 1 in English, hence 2$ is required to skip it. You are free to write this in your translation any way you like as long as it renders correctly. It might be better style for me to write all strings with full positional arguments, but changing the source string would be unnecessary at this point in my opinion, because all existing languages would have to fuzzy merge the change.

    or to provide better understandable quote-signs for all translators (because various languages have different preferred quote-signs):
    %s string extracted from source code for “%2$s”

    I’m not sure I follow 100% here, but as a programmer I tend to use ASCII double quotes. My designer/writer friends like to get angry about this and prefer Unicode quote marks. I’m afraid I am not going to get into a debate about this, and as per my points above, it seems unnecessary to change the source strings when they are already translated. Again you are free to localise quote marks as you see fit in your translations.

    Thread Starter transl8or

    (@transl8or)

    Have you looked at the left side of the translation closely!
    Opened up in Glotpress to see what I mean?
    Its not about the first variable (%s) using the word ‘One’ vs. the number ‘1’.

    It’s about the second variable used in the plural phraze.
    (Gosh that’s just difficult to explain, so sorry if I bug you again.)

    At the moment that plural phrase gives me:
    %s strings found in %s
    which might wrongly be: 3 strings found in 3
    instead of: 3 strings found in filname.po

    Plugin Author Tim W

    (@timwhitlock)

    I have looked closely, and I don’t see any problem.

    At the moment that plural phrase gives me:
    %s strings found in %s
    which might wrongly be: 3 strings found in 3

    No. It won’t. Where are you seeing it render like this?

    The following are equivalent in PHP:

    %s strings found in %s
    %s strings found in %2$s
    %1$s strings found in %2$s

    None of these can possibly render “3 strings found in 3”. This is easily proven with this script:

    <?php
    printf("%s strings found in %s\n",3,'filename.po');
    printf("%s strings found in %2\$s\n",3,'filename.po');
    printf("%1\$s strings found in %2\$s\n",3,'filename.po');
    

    An example of an incorrect string would be this:

    %1$s strings found in %s

    That would print “3 strings found in 3” as you can see with this script:

    <?php
    printf("%1\$s strings found in %s\n",3,'filename.po');
    Thread Starter transl8or

    (@transl8or)

    I will try to explain it again, from the point of view I came from while going through the strings on translate.w.org. Even though I’m not a professional translator.
    Maybe you can help to find the place where the correction needs to be done.
    (Let aside the language and coder/or/designer quote-thing, I shouldn’t have gone so deep into it here, nor to ask for comments on the following string (1).)

    I (with PTE rights for all german theme and plugin projects) actually wanted to improve the plural form of the following string just by adjusting the quotes (your ASCII double quotes) with the common quotes in german, that are part the handbook for german polyglots here at

    (1) See: LocoTranslate-String-1-withSingular-Plural

    Then I saw that the variables made in the plural form differ, which might cause a warning by glotpress btw, and I looked closer to see were the problem is. At first sight it looks like the translator has made a mistake and I better change the second variable in the plural form (and quotes according our german style – which is more minor) …

    But, at second sight I came around another string that needs a singular and plural form too.

    (2) See: LocoTranslate-String-2-withSingular-Plural

    There the variables are in the singular as well in the plural form translated like the way they should – looking at the original. (Only minor tiny thing is that the german plural misses an “s” at the end of the word “String” too.)

    And then there is another string with a need for a singular and plural form too.

    (3) See: LocoTranslate-String-3-withSingular-Plural

    Here everything seems to be alright. The singular and plural original above the input form and the current translations.

    But (1) and (3) follow the same pattern. And that’s why I thought the mistake could also be at your side in the orignals of (1).
    That might mean you have to change it there to
    Singular: One string extracted from source code for “%2$s”
    Plural: %s strings extracted from source code for “%2$s” (Instead of: %s strings extracted from source code for “%s”)

    so that the translation and the translator robertskiba in (1) is right.

    ROFL
    I feel now like back in the 90’s at some math lessons, learning how to make a proper proof and having coding lessons (back then in Pascal, C or C++). I really appreciate your effort and getaway into the details of PHP.
    At least you got me laughing and understanding various points of views (and a little bit confused).

    Thanks a lot 🙂 @timwhitlock
    And if you are in the UK/USA: Happy Thanksgiving!

    – – – – – – – –

    Also, I haven’t found it rendered somewhere in the interface of Loco Translate in WordPress until now.
    It’s just a bit difficult sometimes to setup a test environment where you can find all the translated strings of a project. Looking at the interface of LT in WP is mostly part of my 2nd and 3rd cycle when proof reading translations in use. If the grammar is right, the wording fits the interface (eg words are to long for a button etc.), or just a typo was made and a variable or HTML entity isn’t shown correct at all …
    Not to speak about the various types of consistency (among words across WordPress projects, among words/phrases within a certain project and among the informal/default and formal german versions of all projects on w.org).

    Thread Starter transl8or

    (@transl8or)

    Hey @timwhitlock,

    I just had a closer look at your code and must admit that I do not understand PHP that well so that I might understand your above attempt to explain it because the (1), (2) and (3) look the same for all translators in Glotpress, Poedit or Loco Translate. But the coding behind it is different so it’s also difficult to apply your above attempt with the printf() function to the following.

    Here I go again:

    (1)
    src/package/Debugger.php:186

    $str = _n( 'One string extracted from source code for "%2$s"', '%s strings extracted from source code for "%s"', $realCount, 'loco-translate' );

    (2)
    src/admin/init/InitPoController.php:196

    $summary = sprintf( _n('One string found in %2$s','%s strings found in %s',$total,'loco-translate'), number_format($total), $potfile->basename() );

    (3)
    tpl/admin/init/init-pot.php:24

    <span>(<?php 
                // Translators: Where %s is the size of a file
                $scan->f( 'size', __('%s on disk','loco-translate') );?>, <?php
                // Translators: Where %s is the size of a file
                $scan->f( 'largest', __('largest is %s','loco-translate') )?>)</span>

    So the final question:
    What would happen if (1) in src/package/Debugger.php:186 is changed to

    $str = _n( 'One string extracted from source code for "%2$s"', '%s strings extracted from source code for "%2$s"', $realCount, 'loco-translate' );

    ???

    Thread Starter transl8or

    (@transl8or)

    Damn, and sorry for the mistake in (3) where I copied the wrong peace of code.

    (3) again, from tpl/admin/init/init-pot.php:24 just to continue the confusion

    <?php 
                // Translators: Where %2$s is the size of a file
                self::e( _n('Excludes one file over %2$s','Excludes %s files over %2$s',$n,'loco-translate'), $n, $scan->large )?>

    But that’s actually not the main point of this thread.

    Plugin Author Tim W

    (@timwhitlock)

    So the final question: What would happen if (1) in src/package/Debugger.php:186 is changed to …

    Nothing would happen to how it displays. It will print the exact same English text. If you format your German the same way it will print the exact same German text.

    What would happen is any existing translations of the original text will have to be fuzzy merged, or they would be dropped. Hence my reluctance to make a redundant change.

    For completeness it should probably have been written as ‘%1$s strings extracted from source code for “%2$s”‘, but this change would be equally redundant. I will try to observe this style in future for new strings.

    As I’ve also said, you are free to write your German placeholders anyway you like. If GlotPress shows a warning then it must only be doing a trivial comparison and doesn’t know they are actually equivalent. I do not use GlotPress and cannot comment on its capabilities.

    If people in larger numbers start asking me to change the formatting of existing source strings to fall in line with some particular best practice then I will. But for now, existing sources will stay as they are unless the wording needs to change.

    I thank you for all your feedback and I have already modified some translator comments as you suggested. However this issue has used over an hour of my time and I really don’t have anything more to say on the matter.

    Thread Starter transl8or

    (@transl8or)

    OK

    OK

    Yes. Please try the style with the two placeholders in future versions. Easier to understand for non-coders.

    No. Your placeholders per se are not english nor german and are better the same as the original textstring provides them (the formatting around them is secondary – locale specific quote signs back and forth)

    OK

    OK. Translator comments are always welcome cos our view is often quite narrow and it’s sometimes a challenge to find the best wording in the given context.

    I had almost a sleepless night, last night and a puzzled mind. Next time I will not only think twice or thrice before I start an english conversation with a coder. I better sleep on it for a night. So what is an hour?
    Looking forward to the next (improved) release. 🙂

    I also had the same problem, too.
    Please author check this issue

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Variables in singular/plural strings seem to be set wrong’ is closed to new replies.