Skip to content

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

@peterjaap

Description

@peterjaap

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions