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

Use key for Auto Translation when base language is not found #378

Closed
peterjaap opened this issue Nov 2, 2020 · 5 comments
Closed

Use key for Auto Translation when base language is not found #378

peterjaap opened this issue Nov 2, 2020 · 5 comments
Labels

Comments

@peterjaap
Copy link

peterjaap commented Nov 2, 2020

Scenario;

  • My keys are English strings
  • My base language is English
  • My target language is Dutch
  • I'm using the Google Auto Translate option

The Translation Manager shows;

image

This is because I don't have an English "translation" for the English string.

When I start the Auto translate option, I now get this error;

Argument 1 passed to Illuminate\Support\Str::Tanmuhittin\LaravelGoogleTranslate\{closure}() must be of the type string, null given, called in /data/kapiteinkoko/app2/vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php on line 88

The quick fix is this, but I'm not sure this is the right way to fix this in all scenarios;

- $translated_text = Str::apiTranslateWithAttributes($base_string->value, $newLocale, $base_locale);
+ $translated_text = Str::apiTranslateWithAttributes($base_string->value ?? $base_string->key, $newLocale, $base_locale);
@stale
Copy link

stale bot commented Jan 1, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.

@stale stale bot added the stale label Jan 1, 2021
@stale stale bot closed this as completed Jan 8, 2021
@Wiz-Amit
Copy link

Same issue

@Wiz-Amit
Copy link

Fix this using by #387

@keyur-nextgen
Copy link

not solved
i have Str::macro('apiTranslateWithAttributes', function (string $text, string $locale, string $base_locale = null) line

@HyperDesignCo
Copy link

  • $translated_text = Str::apiTranslateWithAttributes($base_string->value, $newLocale, $base_locale);

where this file located

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants