Code Monkey home page Code Monkey logo

laravel-translation's People

Contributors

danijelk avatar devinfd avatar eldor avatar epocdotfr avatar grantholle avatar laravel-shift avatar makije avatar naincykumariknoldus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-translation's Issues

Comma doesn't work

When I have a translation like this:
__('Subsequently click on \'scan a barcode\', after which the camera will activate, and point the camera at the QR code.')

The translation will be created is:
"Subsequently click on \\'scan a barcode\\": "Subsequently click on \\'scan a barcode\\"

If I remove the comma from the translation, like this:
__('Subsequently click on \'scan a barcode\' after which the camera will activate, and point the camera at the QR code.')

Then the translation is correct:
"Subsequently click on \\'scan a barcode\\' after which the camera will activate, and point the camera at the QR code.": "Subsequently click on \\'scan a barcode\\' after which the camera will activate, and point the camera at the QR code."

Translations with an quotes

Hi,

Very nice packages. Makes translating the site a alot easier.
I have an issue with a test like:

If you don't no what

As a key it's added with \ in front of the quote. This results in a json key that isn't found in the website and doens't get translated.

Kind regards,

Erwin

Possibility to add terms rather than syncing them

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.

Follow symlinks; allow whitespace chars in the scan command

Hello!

I made a PR to fix the following issues:

  • Symbolic links aren't followed
    This allows to scan files in directories which are symlinked (i.e when locally developing a Composer package)
  • The regex used by the Finder in the scan command isn't permissive enough to find translation methods laid out like this:
    trans(
        'group.message',
        ['fdsfd']
    );
    Simply allowing whitespace chars at specific places fixes the issue, as you can see in this snippet: https://regex101.com/r/MT9t0Y/1

The PR: #9

`translation:download` command is trimming all translations

Hello all,

Say I have a translation in my source code which is formatted like this:

trans(' with :assets', ['assets' => $assets]); // Notice the whitespace prefixing the translation

In the POEditor interface, when translating this sentence to another language, the aforementioned whitespace should remain. Which is perfectly fine and well-handled by POEditor. It's even giving you a visual hint about this whitespace. Example in French:

image

However, when downloading translations using the translation:download command, all translations are trimmed. Excerpt from the resulting fr.json file:

" with :assets": "avec :assets",

Looks like it's on-purpose: src/Translation.php#L127. Why such trimming?

Thank you in advance!

Escaped slashes

Hi!

I'm having problems with slashes in my terms, like when I have html tags.

I would suggest adding JSON_UNESCAPED_SLASHES in this line.

It will be very helpfull if user can manually add extra files(or directories) to scan.

Thank you for cool package.
I applied this package to my project and the result is very good.

Except one thing that package scans only *.php and *.vue.

How about the functionality which allows user can manually add files or directories to scan?
something like...

# config/translation.php
...
'extra_files' => [
    resource_path('js/something.js'),
    resource_path('scripts/*.js'),
],
...

I thought that it would be very convenient if this kind of functionality is available.

Thank You.

Q: trim() expects parameter 1 to be string, array given - Key/Value trim error?

Hi there

Thanks for this convenient package.

I added the compsoer package, configured everything and wanted to download our POEditor translations. It kicks off after php artisan translation:download with Preparing to download languages and all looks good but then it fails with trim() expects parameter 1 to be string, array given.

I checked where and it is in the Translation.php line 123.
I dumped what is tried to be trimed here, and the input entry is for example

array:1 [
  "teams.tab_button.my" => "My Teams"
]

Isn't that correct? Key and Value as we prepared.

Any hint on what the problem might be would be awesome.

Thanks a lot in advance

Coding and capturing long / multi-line strings

PR #15 addresses only one of two use case I have.

Another use case which is more difficult to solve is translations of long or multi-line strings e.g.:

Example 1.

__("Part 1 of a long string.\n" .
"Part 2 of a long string.")

You could e,g. include the opening and closing quotations, and then do eval("return " . $match . ";") which will work on the above example, but (obviously) use of eval is potentially dangerous.

Note: In the above example we could have coded it (inconsistently but for good reasons) in a way which would break #15:

__("Part 1 of a 'long' string.\n" .
'Part 2 of a "long" string.')

I guess we could probably code this into a regex \(\s*(?:*'(.*)'|"(.*)")(?:\s*\.\s*(?:*'(.*)'|"(.*)"))*\s*\). See https://www.phpliveregex.com/p/FQQ for a non-working example (which doesn't handle (say) 3 or more lines - but we can probably make this work somehow).

Example 2.

__(<<<XYZ
    Line 1 of a multi-line string.
    Line 2 of a multi-line string.
    XYZ);

(Obviously) this is difficult to do a regex for, and performance is likely to be impossibly slow if we don't use regex. So this form is probably not sensible to support.

translation:upload command overwrites translations with --scan option

Hello,

First of all thx for your awesome-package.
Sadly I've encountered a bug recently:

When running:
php artisan translation:upload --scan

All my english-translations are replaced by the translation-keys.

Before it always just scanned the repo for new translation-keys and added them to poeditor without changing the translations.

Laravel-version: 10
package-version: 3.0.8

Best Regards,
Del

Installation on Laravel 9 conflict (symfony/finder v6.0.3)

Hi, Laravel 9 packs symfony/finder v6.0.3 so can not be installed, a small change in composer.json line 23 needed

- vemcogroup/laravel-translation[3.0.3, ..., 3.0.6] require symfony/finder ^4.3|^5.0 -> found symfony/finder[v4.3.0-BETA1, ..., 4.4.x-dev, v5.0.0-BETA1, ..., 5.4.x-dev] but the package is fixed to v6.0.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

vue-i18n translation function $t() not scanning

I added translation functions from kazupon/vue-i18n to my config/translation.php as follows:

'functions' => ['__','$t','this.$t'],

However, the scan didn't catch any translation strings from my Vue components. From a bit of testing, it seems to be an issue with the $ symbol. Is there any way I could make this work?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.