nikaia / translation-sheet

Translating Laravel languages files using a Google Spreadsheet.
GNU General Public License v3.0
291 stars 60 forks source link

String-keys causing issues #49

Closed LasseRafn closed 4 years ago

LasseRafn commented 4 years ago

Getting the following when using the push command:

Writing translations in the spreadsheet

In REST.php line 118:

  {                                                                                                                   
    "error": {                                                                                                        
      "code": 400,                                                                                                    
      "message": "Invalid JSON payload received. Unknown name \"0\" at 'data.values': Cannot find field.\nInvalid JS  
  ON payload received. Unknown name \"1\" at 'data.values': Cannot find field.\nInvalid JSON payload received. Unkno  
  wn name \"2\" at 'data.values': Cannot find field.\nInvalid JSON payload received. Unknown name \"3\" at 'data.val  
  ues': Cannot find field.\nInvalid JSON payload received. Unknown name \"4\" at 'data.values': Cannot find field.\n  
  Invalid JSON payload received. Unknown name \"5\" at 'data.values': Cannot find field.\nInvalid JSON payload recei  
  ved. Unknown name \"6\" at 'data.values': Cannot find field.\nInvalid JSON payload received. Unknown name \"7\" at  
   'data.values': Cannot find field.\nInvalid........

I tried editing TranslationsSheet.php -> writeTranslations and added:

$translations = array_values($translations);

And now it works.. I think it is because the package gives array keys as strings ("0", "1") but after array_slice it turns into integers.

MarGul commented 4 years ago

@LasseRafn solution worked for me as well. The PR is still open.