Laravel-Backpack / LangFileManager

A quick interface to edit Laravel language files, for Backpack.
http://backpackforlaravel.com
MIT License
92 stars 42 forks source link

Trying to get property of non-object #69

Closed swingywc closed 5 years ago

swingywc commented 5 years ago

Step to reproduce:

  1. I created two languages in Languages table, Traditional Chinese with code hk and Simplified Chinese with code cn.
  2. Add two files resources/lang/cn/home.php and resources/lang/hk/home.php with following structure:
    <?php
    return [
    'title' => 'hello there',
    ];
  3. Go to Site texts table, try to read the result in Home tab.
  4. Crash with below section error.

Error encountered

Trying to get property of non-object (View: /project/ifinance-web/vendor/backpack/langfilemanager/src/resources/views/translations.blade.php)

in line 64:

<h4><?php echo e(trans('backpack::langfilemanager.language_text', ['language_name' => $browsingLangObj->name])); ?></h4>

I try to debug with {{ dd($browsingLangObj) }} before that line and found out that it is null.

Please help me, thanks :(

welcome[bot] commented 5 years ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication mediums:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

swingywc commented 5 years ago

Should the $browsingLangObj change to $currentLangObj too? I am confused.

swingywc commented 5 years ago

Found out that in config/backpack/crud.php there are no hk or cn language code to use.

There are two solutions:

  1. Increase languages table abbr length and Lanuages rules to allow language code like zh_Hant_HK, zh_Hans_CN etc.
  2. Make custom languages code in config/backpack/crud.php, i.e. hk and cn.

My current solution is rebuilding project and use solution 2. @tabacitu should it allow typing language code more than two character? referencing issue #1

By the way, closing issue.