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

An issue accured when no {lang}.json file provided #11

Open
WatheqAlshowaiter opened this issue Oct 25, 2024 · 1 comment
Open

An issue accured when no {lang}.json file provided #11

WatheqAlshowaiter opened this issue Oct 25, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@WatheqAlshowaiter
Copy link
Contributor

when no en.json file provided, the package will create en.php file translation which is not working.

the php language files not working until they are inside language folders.

the fix simply to create language json file if not exists.

// the place of the issue
    protected function getTargetLanguagePath(string $targetLanguage): string
    {
        $file = config('translator.language_folder') . "/{$targetLanguage}.json";
        if (!file_exists($file)) {
            $file = config('translator.language_folder') . "/{$targetLanguage}.php";
        }

        return $file;
    }

Secondly, I hope the package be able to add php files from config like msg.php which we can use php files for translation using this package, because we can use language ui like https://github.com/MohmmedAshraf/laravel-translations package, and the flexibility of nesting keys, etc

@Bottelet
Copy link
Owner

Bottelet commented Oct 25, 2024

I definitely think just adding the en.php is wrong. I didn't realize it did that. I will look into it.

I shorty looked into making the package work with other file structures the main problem with it was the freedom to basically do anything, meaning I had to figure out the file structure / php structure.

__ ('some.deep.nested.text')

/ en 
   /some.php
   [
      'deep' => [
          'nested' => [
                 'text' => 'translation'
               ]
          ]
    ]
/ en 
   /some/deep/nested.php
   [
      'text' => 'translation'
   ]
  

Take the example above, both are valid, and there was a lot to keep track of so I stopped it, in search of a better solution.

I didn't know about @MohmmedAshraf laravel-translations. and definitely agree a good goal is that it's compatible.

@WatheqAlshowaiter WatheqAlshowaiter changed the title and issue when no lang.json file provided An issue accured when no {lang}.json file provided Oct 25, 2024
@Bottelet Bottelet added the enhancement New feature or request label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants