tanmuhittin / laravel-google-translate

Translate translation files to other languages using google translate or another translation api
MIT License
424 stars 71 forks source link

Multimensional PHP Arrays #25

Closed kaneymhf closed 4 years ago

kaneymhf commented 4 years ago

When working with multidimensional arrays, the function doesn't work when is checking for already translated strings and printing the skipped value, because try to convert Array to String. I just left the search function for strings already translated working recursively.

briavers commented 4 years ago

Does this fix the issue where having multi dimensional array you get an empty translation file

kaneymhf commented 4 years ago

I use multidimensional arrays in my project, and has worked correctly in my tests. I tested various scenarios and all tests passed.

briavers commented 4 years ago

I think my issue might lay somewhere different as

<?php

return [
    'names' => [
        'user' => 'User',
        'users' => 'Users',
        'supplier' => 'Supplier',
        'suppliers' => 'Suppliers',
        'customer' => 'Customer',
        'customers' => 'Customers',
        'order' => 'Order',
        'orders' => 'Orders',
        'order_line' => 'Order line',
        'order_lines' => 'Order lines',
    ],

    'fields' => [
        'reference' => 'Reference',
        'name' => 'Name',
        'email' => 'Email',
        'password' => 'Password',
        'role' => 'Role',
        'location' => 'Location',
        'webhook' => 'Webhook',
        'created_at' => 'Created At',
        'updated_at' => 'Updated At',
        'deleted_at' => 'Deleted At',
        'order_ref' => 'Order Ref',
        'file_ref' => 'File Ref',
        'make' => 'Make',
        'vin' => 'VIN',
        'first_reg' => 'First Registration',
        'preferred_supply_date' => 'Preferred Supply Date',
        'comments' => 'Comments',
        'exported_at' => 'Exported At',

        'position' => 'Position',
        'part_number' => 'Part Number',
        'part_description' => 'Part Description',
        'quantity' => 'Quantity',
        'gross_price' => 'Gross Price',
        'price' => 'Net price',
        'ordered_at' => 'Ordered At',
        'delivered_at' => 'Delivered At',
        'cancelled_at' => 'Cancelled At',

    ],
];

fails and just gives me an empty array as translated file while

return [
    'mail' => [
        'success' => 'Notification mail was sent successfully.',
    ],
    'login' => [
        'success' => 'Welcome! You are now logged in!',
    ],
];

succeeds. Both are the exact same of build (expect the size) but one fails and one succeeds. guess i'll have to manualy translate :(

briavers commented 4 years ago

Changed the name of the file from resources to customResources and it worked...

tanmuhittin commented 4 years ago

Thank you for the contribution. Please use dev-master for testing. If no problem occurs within 2 weeks I am planning a new version release.