vemcogroup/laravel-translation

Possibility to add terms rather than syncing them

Closed this issue · 6 comments

This package is amazing, simple and easy to use - so thank you for that! :)

But we have found a problem using it on larger projects, due to the implementation of the upload method. The command php artisan translation:upload will upload the translations by https://api.poeditor.com/v2/projects/sync.

This will sync your terms and delete the ones that are no longer in your translation file. This is a problem, for us, because it is not unusual to work on two features at the same time.

Example

Feature 1, is being developed and a few terms are added to the project. A developer will push the terms via php artisan translation:upload and the new terms he has added are now uploaded to POEditor for translators to work on. The feature is not released yet.

Feature 2, is being developed simultaneously and another developer now pushes his new translations. Translations from feature 1 are now deleted due to the syncing mechanism because the two branches are both ahead.

This is taken from POEditor API documentation under Sync Terms;

Please use with caution. If wrong data is sent, existing terms and their translations might be irreversibly lost.

Question:

Would it be possible to utilise the "add terms" instead of syncing as the default upload method? Of cause it should be possible to sync translations, but I find this dangerous due to the way POEditor has implemented this feature.

We have lost a few translations like this unfortunately.

eldor commented

Hi @nicolasbuch
Thank you for the kind words.

Have you tried using the scan method before using upload?

php artisan translation:scan {--merge : Whether the job should overwrite or merge new translations keys}

Then I think it keeps the other translations in your file.

Have you tried using the scan method before using upload?

php artisan translation:scan {--merge : Whether the job should overwrite or merge new translations keys}

Yes sure, this is what we do today. The php artisan translation:scan --merge command does not help us, because the translations from "feature 1" simply dont exist in the branch of "feature 2".

Our CI/CD setup will run below on each merged PR:

php artisan translation:download
php artisan translation:scan --merge
php artisan translation:upload

UPDATED: diagram (working on two release versions at the same time):

/master
|
|_ _ /release/a
|       |
|       |_ /feature/1
|          |
|          |_ new translations pushed when "feature 1" is merged into "release a"
|
|_ _ /release/b
        |
        |_ /feature/2
           |
           |_ new translations pushed when "feature 2" is merged into "release b"
           |_ translations from "feature 1" removed from POEditor due to sync strategy

Hope this makes a bit more sense

eldor commented

Ok, now i see what you mean and can understand your issue.
We could make another command like php artisan translation:terms that only add terms to PoEditor.

https://poeditor.com/docs/api#terms_add

Then you dont need to run the upload command only scan -> terms -> download and it shouldn't remove terms anymore.

Would that be a suitable solutions for you guys?

Would that be a suitable solutions for you guys?

That would be amazing! Let me know if there is anything I can do to assist

eldor commented

I've added version 3.0.2 that have the new command: https://github.com/vemcogroup/laravel-translation/releases/tag/3.0.2
Could you test it out and let me know if there is any issues

Could you test it out and let me know if there is any issues

Works like a charm, thank you!