Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation on module translation #321

Merged
merged 6 commits into from Sep 9, 2019

Conversation

@eternoendless
Copy link
Member

commented Aug 8, 2019

Fixes #284

Copy link
Member

left a comment

Awesome !

Can we also provide a module which is using the new system and still retro compatible with 1.6?

There is no need to be a big module: only a hello-world like that we could comment and share here.


Now, when working in internationalization, it's better not to make assumptions regarding spacing and positioning of variables. For example, in French, there should be a non-breaking space before the exclamation mark (`!`), but not in other languages. How can we handle this?

In PrestaShop, you can interpolate variables within your wordings using using [sprintf replacement markers](https://php.net/sprintf), such as `%s` or `%1$s`. Using this feature, we could get rid of the explicit concatenation of "Hello, ", "$my_module_name" and "!", and let it depend on the translated wording:

This comment has been minimized.

Copy link
@mickaelandrieu

mickaelandrieu Aug 9, 2019

Member
- using using
+ using

```php
{l
s='If you want a category to appear in the menu of your shop, go to [1]Modules > Modules & Services > Installed modules.[/1] Then, configure your menu module.'

This comment has been minimized.

Copy link
@mickaelandrieu

mickaelandrieu Aug 9, 2019

Member

couldn't we introduce a new best practice here? WDYT about that:

[modules-link]Modules > Modules & Services > Installed modules.[/modules-link]

I'm not convinced it will work as I hope.

This comment has been minimized.

Copy link
@eternoendless

eternoendless Aug 9, 2019

Author Member

Yes it should work 👍

$_MODULE['<{mymodule}prestashop>mymodule_0f40e8817b005044250943f57a21c5e7'] = 'Aucun nom fourni';
```

This file shouldn't be modified manually! It is meant to be edited through the PrestaShop translation interface.

This comment has been minimized.

Copy link
@mickaelandrieu

mickaelandrieu Aug 9, 2019

Member

you may put this advice inside a note or a warning block.

`ModuleAdminController` and `ModuleFrontController` can access the module instance via the `$this->module` property.

```php
// file: controllers/front/something.php

This comment has been minimized.

Copy link
@mickaelandrieu

mickaelandrieu Aug 9, 2019

Member

question: what will happens if I have another file named something.php in my module?

This comment has been minimized.

Copy link
@eternoendless

eternoendless Aug 9, 2019

Author Member

AFAIK they will both treated as if they were the same file

@eternoendless

This comment has been minimized.

Copy link
Member Author

commented Aug 9, 2019

Can we also provide a module which is using the new system and still retro compatible with 1.6?

It's possible, but it won't be nice 😅. You'd need two copies of templates that use {l} smarty tag (one for 1.6 with mod= and one for 1.7.6+ with d=) and use one or the other according to the current PS version. You'd also have to either use different controllers or different implementations that use the l() function or the trans() function.

The new translation system won't pick up wordings used through l() either.

@matks
matks approved these changes Sep 9, 2019
@matks

This comment has been minimized.

Copy link
Contributor

commented Sep 9, 2019

Thank you @eternoendless

@matks matks merged commit e840a6d into PrestaShop:master Sep 9, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.