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

Cannot import all files to database #431

Open
ronrun opened this issue Oct 2, 2022 · 1 comment
Open

Cannot import all files to database #431

ronrun opened this issue Oct 2, 2022 · 1 comment
Labels

Comments

@ronrun
Copy link

ronrun commented Oct 2, 2022

I have lang files:

\lang
  en\
    ocadmin\
      common\
        column_left.php
      setting\
        setting.php
    auth.php
    pagination.php
    password.php
    validation.php
  zh-Hant\
    ocadmin\
      common\
        column_left.php
      setting\
        setting.php
    auth.php
    pagination.php
    password.php
    validation.php

php artisan translations:import

en language:
the root four files of language folder are in database, but none of all other files

zh-Hant:
Only "ocadmin/common/column_left" in database. The original four files auth.php... are missing, and setting/abc.php is missing.

So strange...

vendor\barryvdh\laravel-translation-manager\src\Manager.php

                if (! $vendor) { // line 96
                    $translations = \Lang::getLoader()->load($locale, $group);
                } else {
                    $translations = include $file;
                    $group = 'vendor/'.$vendorName;
                }

                if ($translations && is_array($translations)) { // line 103
                    foreach (Arr::dot($translations) as $key => $value) {
                        $importedTranslation = $this->importTranslation($key, $value, $locale, $group, $replace);
                        $counter += $importedTranslation ? 1 : 0;
                    }
                }
                // I add 3 lines. Why do I get emtpy $translations?
                else{ 
                    echo "<pre>", print_r($group, 1), "</pre>\r\n"; exit;
                }

Why do I get emtpy $translations?


I fixed.

vendor\barryvdh\laravel-translation-manager\src\Manager.php

    public function importTranslations($replace = false, $base = null, $import_group = false)
    {
        ...
                if ($subLangPath != $langPath) {
                    //$group = $subLangPath.'/'.$group;
                    $group = str_replace($langPath.'/', '', $subLangPath) . '/' . $group;
                }

langPath
D:/Codes/PHP/laravel.test/httpdocs/lang/en

subLangPath
D:/Codes/PHP/laravel.test/httpdocs/lang/en/lang/en/ocadmin/common

group (before $group = $subLangPath.'/'.$group;)
column_left

group (after that line)
D:/Codes/PHP/backgarden.chinabing.test/httpdocs/lang/en/ocadmin/common/column_left

What it need is 'ocadmin/commoncolumn_left'

So I write another line to handle it. It seems works!

For export

    public function exportTranslations($group = null, $json = false)
    {
        // $group = basename($group);
        // $basePath = $this->app['path.lang'];
@stale
Copy link

stale bot commented Jun 18, 2023

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 Jun 18, 2023
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

1 participant