Translation... disappears after ~one second

  • Weird one...


    I'm using for my language complicated formulas (for plurals).


    For example:

    Code
    <item name="wcf.date.relative.minutes"><![CDATA[{if $minutes == 1}minutę{else}{if ($minutes > 4 && $minutes < 22) || (($minutes % 10 == 1 || $minutes % 10 == 5 || $minutes % 10 == 6 || $minutes % 10 == 7 || $minutes % 10 == 8 || $minutes % 10 == 9 || $minutes % 10 == 0) && $minutes > 4)}{#$minutes} minut{else}{#$minutes} minuty{/if}{/if} temu]]></item>

    For some reason it is working correctly just for a moment, for example I see at my profile:




    But after ~second correct phrase is replaced with:




    In Chrome console I can read:


    Code
    /wbb5/js/WoltLabSuite/Core/Template.js:45 Parse error on line 1:
    ...= 1}minutę{else}{if ($minutes > 4 && $mi
    -----------------------^
    Expecting 'T_ANY', 'T_WS', '=', 'T_VARIABLE', 'T_VARIABLE_NAME', 'T_QUOTED_STRING', got '('

    Not sure if it is bug, but for a moment phrase is correct...

    • Official Post

    It works just some seconds or one minut or some minuts exactly before having this message ?

    To clarify the behavior observed by the thread starter: The relative time is statically added to the template via PHP, then a JavaScript function kicks in that will take care of periodically updating the values, including an update of the initial value. This process fails due to a parser error in the JavaScript function, it seems to struggle with the brackets and at this point I'm not sure if there is just a mismatch or an actual issue with the parser.

  • To clarify the behavior observed by the thread starter: The relative time is statically added to the template via PHP, then a JavaScript function kicks in that will take care of periodically updating the values, including an update of the initial value. This process fails due to a parser error in the JavaScript function, it seems to struggle with the brackets and at this point I'm not sure if there is just a mismatch or an actual issue with the parser.

    Thanks for this information Alexander :)

    • Official Post

    Hi

    actual issue with the parser

    this one. The grammar did not support the use of parentheses for grouping of expressions, but only for function calls.


    The issue will be fixed with the next update. I tested the change with a few more complex templates of mine and the attempted translation in this bug report.


    Fixing the issue yourself is possible, but not exactly easy. I recommend to wait. These are the relevant commits nonetheless:


    https://github.com/WoltLab/WCF…3bb767707f0aafb6b4a2b07c9

    https://github.com/WoltLab/WCF…a44a6f8bf3fadb40da37f16ec

  • Thanks guys for help :)


    Tim Düsterhus - tested Your fix - it's OK, thanks :D (I'm completing translation on localhost, so it was no problem for me to check and no risk ;) )


    marcbelgique - plurals in Polish language are a little bit crazy ;)


    Result of my example is:

    - minutę temu (one minute ago)

    - 2 minuty temu

    - 3 minuty temu

    - 4 minuty temu

    - 5 minut temu

    - 6 minut temu

    ...

    - 22 minuty temu

    - 23 minuty temu

    - 24 minuty temu

    - 25 minut temu


    Unfortunately I have to use this construction nearly for anything - minutes, hours, posts, replies, comments... My brain hurts when I need to fit this construction to every case 8o I still need to do some finetuning (112, 113, 114, 212, 213, 214, etc. will give wrong plural form, but for example this is not needed for minutes, because they will be replaced to hours anyway, etc.), but for most cases this construction is OK ;)


    My translation is ready (still only for Forum), I'm just checking it now and that's why I spotted this one ;) I'm going to release it hopefull in next days ;) Thanks for fixing this Tim Düsterhus :)

    • Official Post

    PolUser The following expression should have the same result:

    Code
    {if $minutes == 1}
        minutę
    {elseif $minutes > 4 && ($minutes < 22 || ($minutes % 10 < 2 || $minutes % 10 > 4))}
        {#$minutes} minut
    {else}
        {#$minutes} minuty
    {/if}

    Newlines have been added for readability, making it easier for you to check it. Basically I've reduced the check for $minutes > 4 to one time and changed the modulo check to just exclude the results 2, 3 and 4.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!