diff --git a/src/Spreadsheet.php b/src/Spreadsheet.php index 6c2de7a..d315d6c 100644 --- a/src/Spreadsheet.php +++ b/src/Spreadsheet.php @@ -3,6 +3,7 @@ namespace Nikaia\TranslationSheet; use Illuminate\Support\Str; +use Nikaia\TranslationSheet\Util; use Nikaia\TranslationSheet\Client\Api; use Nikaia\TranslationSheet\Sheet\Styles; use Nikaia\TranslationSheet\Sheet\TranslationsSheetCoordinates; @@ -83,6 +84,10 @@ public function getHeader() public function getCamelizedHeader() { return array_map(function ($item) { + if (in_array($item, Util::asArray($this->getLocales()))) { + return $item; + } + return Str::camel($item); }, $this->getHeader()); } diff --git a/src/TranslationSheetServiceProvider.php b/src/TranslationSheetServiceProvider.php index a4b1e5c..11fdeeb 100644 --- a/src/TranslationSheetServiceProvider.php +++ b/src/TranslationSheetServiceProvider.php @@ -3,6 +3,7 @@ namespace Nikaia\TranslationSheet; use Illuminate\Support\ServiceProvider; +use Nikaia\TranslationSheet\Util; use Nikaia\TranslationSheet\Client\Client; use Nikaia\TranslationSheet\Commands\Lock; use Nikaia\TranslationSheet\Commands\Open; @@ -48,7 +49,7 @@ private function registerSpreadsheet() $this->app->singleton(Spreadsheet::class, function () { return new Spreadsheet( $this->app['config']['translation_sheet.spreadsheetId'], - $this->asArray($this->app['config']['translation_sheet.locales']) + Util::asArray($this->app['config']['translation_sheet.locales']) ); }); } @@ -66,15 +67,4 @@ private function registerCommands() Open::class, ]); } - - private function asArray($value) - { - if (is_array($value)) { - return $value; - } - - return array_filter(array_map(function ($item) { - return trim($item); - }, explode(',', $value))); - } } diff --git a/src/Util.php b/src/Util.php index f9efbb7..6fc603a 100644 --- a/src/Util.php +++ b/src/Util.php @@ -36,4 +36,15 @@ public static function keyValues($values, $keys) return array_combine($keys, $values); }); } + + public static function asArray($value) + { + if (is_array($value)) { + return $value; + } + + return array_filter(array_map(function ($item) { + return trim($item); + }, explode(',', $value))); + } }