Jump to content

core problem with relative time translation


wayne
 Share

Recommended Posts

I'm starting this topic for a problem I see with the German translations of relative times. But other languages may be affected as well.

You can see the problem when the Lister module shows a column with a past date.

In English it says "3 years ago" and in German it's translated to "3 Jahre vor". But it really should be "vor 3 Jahren".

The phrase is constructed with the single translations of "years" and "ago" in the same order as it is in English.

So the problem is about grammar and word order in the German translation.

Maybe it could be solved by a list of translatable phrases with placeholders, so that it looks like "%d years ago" or in German "vor %d Jahren". That is just a quick thought and it probably should be discussed here before it is posted as an issue on github.

  • Like 5
Link to comment
Share on other sites

  • 1 month later...

Wayne, thanks I think you've done a good job of outlining the issue. Before we attempt to fix it by requiring a re-translation of existing terms, I thought we might try to solve it by making the order of terms translatable. Could you (or anyone else that wants to try) try replacing this line in /wire/core/Functions.php:

return sprintf('%s%d%s%s %s', $prepend, (int) $difference, $space, $period, $tense); // i.e. 2 days ago (d=qty, 2=period, 3=tense)

With these lines:

$quantity = $prepend . $difference . $space; 
$format = __('Q P T', __FILE__); // Relative time order: Q=Quantity, P=Period, T=Tense (i.e. 2 Days Ago)
$out = str_replace(array('Q', 'P', 'T'), array(" $quantity", " $period", " $tense"), $format); 
if($abbreviate === 1) $out = str_replace("$quantity $period", "$quantity$period", $out); 
return trim($out); 

Then translate the /wire/core/Functions.php using the Setup > Languages > Translation tool, and adjust the order of Q, P, and T in the translation engine according to what makes sense with the locality. For instance, it German it sounds like it should be: T Q P.

I'm curious if this solution resolves the issue or if further changes might be necessary. Thanks. 

  • Like 7
Link to comment
Share on other sites

@ryan: the same problem is also found in the module/new section. Seems this has also to be fixed in ProcessModule.module (from line 438 on).

Without the fix from above --> same "wrong" order of words. With the fix in the Functions.php it looks strange?

The order is correct, but must be "vor 1 Tag". There is one more "vor" overlapping the "Tag"?

post-1027-0-74316500-1407505258_thumb.jp

Link to comment
Share on other sites

I haven't checked yet, but maybe the T in "Tag" gets replaced by the translated tense variable, like it's done in "T Q P".

EDIT:

I think it's the following line:

$out = str_replace(array('Q', 'P', 'T'), array(" $quantity", " $period", " $tense"), $format); 

str_replace replaces Q, P and T one after the other. In the second round P gets replaced by the content of $period ("Tag"), that "T" also gets replaced by the content of $tense in the last round.

A solution may be to use prefixes, that wouldn't appear in a translation, like "%Q".

EDIT 2:

Btw ryan, you already pushed that change to github with your last update to ProcessModule. I think this wasn't intended.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...