Improve "ago" string for languages other than English

papi Jo's picture

Using H5P on a WordPress site.

Numbers in brackets refer to the attached screenshot.

On the All H5P Content page, the Last modified column display is correct for English (1) but incorrect for those languages which place the time and time-word(s) in the opposite order, such as French and Spanish. In the current h5p-fr_FR.po file, "ago" has been translated by "avant", which is an - unsatisfactory - attempt at solving the problem (2).

I suggest that the real solution is to attach a parameter to the "ago" string, along the following lines.

1.- in file class-h5p-content-admin.php around line 805
replace
$human_time = human_time_diff($time + $offset, $current_time) . ' ' . __('ago', $this->plugin_slug);
with
$timediff = human_time_diff($time + $offset, $current_time);
$human_time = sprintf(__('%s ago', $this->plugin_slug), $timediff);

2.- using a translation tool such as Poedit, in your wordpress site at /wp-content/plugins/h5p/languages open a language file, e.g. h5p-fr_FR.po; Tab Catalogue->Update from sources.
Translate the "%s ago" string into the current po language, e.g. "il y a %s" for French and Save the file.

See result for French (3) and Spanish (4) on the attached screenshots.

Note.- Also the display of full date as yyyy/mm/dd is quite misleading even for English language users, and should be correctly localized. See my post here: https://h5p.org/node/35289.

 

0
0
Supporter votes Members of the Supporter Network can vote for feature requests. When the supporter network has generated sufficient funding for the top voted feature request it will normally be implemented and released. More about the H5P Supporter Network
tim's picture

Great catch. I've now moved a copy of this to the Feature Request forum.

Would you be able to make a pull request with the code changes you suggested?

papi Jo's picture

Hi tim, today I have made pull requests for my suggested changes to improve the "ago" display for languages other than English.

1.- I have included in my request the French translation file. Translators of other languages should be informed of the change. How to do it? Who will do it?

2.- Although I've used Github for a number of years (for Moodle) this is the first time I have made a "pull request". I thought I would make separate requests for several changes, but I notice that the 2 requests I made today are "merged" into a single request. Is this the normal way of things? I will have a number of other requests to make in the coming days, how can they be made "separate"?

If you prefer you can email me directly at [email protected]

Thanks!

otacke's picture

If you want to create multiple pull requests for multiple features, you should use branches

tim's picture

I agree with otacke, if multiple changes need to happen, your best bet is to create a new branch. 

The benefits of using a new branch are that multiple interdependent changes can be made together. It then becomes easier to merge it into the main codebase as the Core Team can review all the changes at once.

This is what I recommend doing:

  1. Fork a copy of the wordpress plugin repository: https://github.com/h5p/h5p-wordpress-plugin
  2. Make a new branch on your own fork, name it something relevant e.g. translations 
  3. Make all the changes relevant to the branch name
  4. Make a pull request to merge that branch back to the the main one

I would continue doing this for all the different types changes you wish to make. For example, it would have been a bit easier to handle the most recent pull request: https://github.com/h5p/h5p-wordpress-plugin/pull/42 if it was split up into different ones. If you have the time, it would be a tremendous help :) 

papi Jo's picture

Thanks for your suggestions, tim & otacke,

I will look into this and try to understand the best process for my further commits!

papi Jo's picture

Hope I got it right now! Just created a new pull request for the "ago" improvement suggestion.

tim's picture

Good stuff. I'll get round to reviewing it in the next couple of days.