Skip to content

[Translation] With Loco provider, push command replaces dots with hyphens #42395

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

Closed
jmunozco opened this issue Aug 5, 2021 · 8 comments · Fixed by #43967
Closed

[Translation] With Loco provider, push command replaces dots with hyphens #42395

jmunozco opened this issue Aug 5, 2021 · 8 comments · Fixed by #43967

Comments

@jmunozco
Copy link

jmunozco commented Aug 5, 2021

Symfony version(s) affected: 5.3.6

Description
When uploading to Loco by using push command, it appears (in Loco dashboard) dots have been replaced by hyphens, as push command seems to do this replacement and then fails once pull is done

How to reproduce

  1. Create a project and install: composer require symfony/translation and Loco package by composer require symfony/loco-translation-provider and add configuration for locales and domains in translations.yaml. Also create a project in Loco (localise.biz) and configure its API_KEY for read and write permissions and place it in .env file (LOCO_DSN)
  2. Create one controller and use TranslatorInterface to have at least one translatable keystring (with dots)
  3. In the console: debug/translation to confirm there are missing strings (one in this case)
  4. In the console: symfony console translation:update en --force to generate the local file under translations folder
  5. In the console: translation:push to upload to Loco
  6. Check in Loco that it was uploaded and appears incorrectly with hyphens and not with dots

Additional context
In the controller we have this line: $translated = $translator->trans('index.home.msg');

In the generated translations file under /translations folder we have these lines:

      <trans-unit id="FNdkzeB" resname="index.home.msg">
        <source>index.home.msg</source>
        <target>__index.home.msg</target>
      </trans-unit>

And in Loco we have this capture:
Captura de pantalla 2021-08-05 a las 21 00 26

@jmunozco
Copy link
Author

jmunozco commented Aug 5, 2021

This is the repo where error is reproduced: https://github.com/jmunozco/symfony_issue_42395

@OskarStark
Copy link
Contributor

friendly ping @welcoMattic

@welcoMattic
Copy link
Member

Thanks @OskarStark for the ping. It is a very strange behaviour this "transformation" from dot notation to hyphen notation in Loco, I use Loco in some real projects, and I've never see it.

Thanks @jmunozco for the reproducer, I'll try to check it as soon as I can.

@vlad-ghita
Copy link

When creating an asset, if ID is not specified, Loco auto-generates one from text.
Reference.

Thus, provide ID when creating asset.
https://ibb.co/Vjrq7Nq

@welcoMattic
Copy link
Member

@vlad-ghita I think you've found the source of the problem, which is id auto-generation by Loco from the translation key. Your fix seems to be the right way to solve the problem, can you open a PR please?
Thank you

@vlad-ghita
Copy link

I'll try to find some time.

@welcoMattic
Copy link
Member

If you can't, let me know I could later this week

@vlad-ghita
Copy link

Well, I'm a bit busy honestly and I'm not familiar with PR process for Symfony ...

If you can do it, I'd appreciate it.

You could incorporate #43954 as well while at it.

@fabpot fabpot closed this as completed Nov 8, 2021
fabpot added a commit that referenced this issue Nov 8, 2021
… reading (welcoMattic)

This PR was merged into the 5.4 branch.

Discussion
----------

[Loco] Fix Loco Provider ID and pull & push local messages reading

| Q             | A
| ------------- | ---
| Branch?       | 5.3
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #42395 & #43954
| License       | MIT
| Doc PR        |

It fixes Loco push new messages and avoiding Loco auto-generation of ID for each new messages (which use dash notation instead of dot notation IIRC).

And it fixes also the Translation push & pull commands when they read local messages for multiple domains.

Commits
-------

51ea9c8 Fix Loco Provider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants