More peer review of #1856
Separation of concerns, the language file shouldn't really be treated as a data source for the supported encoding options.
This commit is contained in:
parent
a035acdc2c
commit
2ac23cc3c7
|
|
@ -377,24 +377,24 @@ return [
|
|||
'encoding_not_supported_error' => 'Source file encoding is not recognized. Please select the custom file format option with the proper encoding to import your file.',
|
||||
'encoding_format' => 'File encoding',
|
||||
'encodings' => [
|
||||
'utf-8' => 'UTF-8',
|
||||
'us-ascii' => 'US-ASCII',
|
||||
'iso-8859-1' => 'ISO-8859-1 (Latin-1, Western European)',
|
||||
'iso-8859-2' => 'ISO-8859-2 (Latin-2, Central European)',
|
||||
'iso-8859-3' => 'ISO-8859-3 (Latin-3, South European)',
|
||||
'iso-8859-4' => 'ISO-8859-4 (Latin-4, North European)',
|
||||
'iso-8859-5' => 'ISO-8859-5 (Latin, Cyrillic)',
|
||||
'iso-8859-6' => 'ISO-8859-6 (Latin, Arabic)',
|
||||
'iso-8859-7' => 'ISO-8859-7 (Latin, Greek)',
|
||||
'iso-8859-8' => 'ISO-8859-8 (Latin, Hebrew)',
|
||||
'iso-8859-0' => 'ISO-8859-9 (Latin-5, Turkish)',
|
||||
'iso-8859-10' => 'ISO-8859-10 (Latin-6, Nordic)',
|
||||
'iso-8859-11' => 'ISO-8859-11 (Latin, Thai)',
|
||||
'iso-8859-13' => 'ISO-8859-13 (Latin-7, Baltic Rim)',
|
||||
'iso-8859-14' => 'ISO-8859-14 (Latin-8, Celtic)',
|
||||
'iso-8859-15' => 'ISO-8859-15 (Latin-9, Western European revision with euro sign)',
|
||||
'Windows-1251' => 'Windows-1251 (CP1251)',
|
||||
'Windows-1252' => 'Windows-1252 (CP1252)'
|
||||
'utf_8' => 'UTF-8',
|
||||
'us_ascii' => 'US-ASCII',
|
||||
'iso_8859_1' => 'ISO-8859-1 (Latin-1, Western European)',
|
||||
'iso_8859_2' => 'ISO-8859-2 (Latin-2, Central European)',
|
||||
'iso_8859_3' => 'ISO-8859-3 (Latin-3, South European)',
|
||||
'iso_8859_4' => 'ISO-8859-4 (Latin-4, North European)',
|
||||
'iso_8859_5' => 'ISO-8859-5 (Latin, Cyrillic)',
|
||||
'iso_8859_6' => 'ISO-8859-6 (Latin, Arabic)',
|
||||
'iso_8859_7' => 'ISO-8859-7 (Latin, Greek)',
|
||||
'iso_8859_8' => 'ISO-8859-8 (Latin, Hebrew)',
|
||||
'iso_8859_0' => 'ISO-8859-9 (Latin-5, Turkish)',
|
||||
'iso_8859_10' => 'ISO-8859-10 (Latin-6, Nordic)',
|
||||
'iso_8859_11' => 'ISO-8859-11 (Latin, Thai)',
|
||||
'iso_8859_13' => 'ISO-8859-13 (Latin-7, Baltic Rim)',
|
||||
'iso_8859_14' => 'ISO-8859-14 (Latin-8, Celtic)',
|
||||
'iso_8859_15' => 'ISO-8859-15 (Latin-9, Western European revision with euro sign)',
|
||||
'windows_1251' => 'Windows-1251 (CP1251)',
|
||||
'windows_1252' => 'Windows-1252 (CP1252)'
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -361,24 +361,24 @@ return [
|
|||
'encoding_not_supported_error' => 'L’encodage de votre fichier source n’est pas reconnu. Veuillez sélectionner le format d’import personnalisé avec l’encodage adapté pour importer votre fichier.',
|
||||
'encoding_format' => 'Encodage du fichier',
|
||||
'encodings' => [
|
||||
'utf-8' => 'UTF-8',
|
||||
'us-ascii' => 'US-ASCII',
|
||||
'iso-8859-1' => 'ISO-8859-1 (Latin-1, européen occidental)',
|
||||
'iso-8859-2' => 'ISO-8859-2 (Latin-2, européen central)',
|
||||
'iso-8859-3' => 'ISO-8859-3 (Latin-3, européen du Sud)',
|
||||
'iso-8859-4' => 'ISO-8859-4 (Latin-4, européen du Nord)',
|
||||
'iso-8859-5' => 'ISO-8859-5 (Latin, cyrillique)',
|
||||
'iso-8859-6' => 'ISO-8859-6 (Latin, arabe)',
|
||||
'iso-8859-7' => 'ISO-8859-7 (Latin, grec)',
|
||||
'iso-8859-8' => 'ISO-8859-8 (Latin, hébreu)',
|
||||
'iso-8859-0' => 'ISO-8859-9 (Latin-5, turc)',
|
||||
'iso-8859-10' => 'ISO-8859-10 (Latin-6, nordique)',
|
||||
'iso-8859-11' => 'ISO-8859-11 (Latin, thaï)',
|
||||
'iso-8859-13' => 'ISO-8859-13 (Latin-7, balte)',
|
||||
'iso-8859-14' => 'ISO-8859-14 (Latin-8, celtique)',
|
||||
'iso-8859-15' => 'ISO-8859-15 (Latin-9, européen occidental révisé avec le signe euro)',
|
||||
'Windows-1251' => 'Windows-1251 (CP1251)',
|
||||
'Windows-1252' => 'Windows-1252 (CP1252)'
|
||||
'utf_8' => 'UTF-8',
|
||||
'us_ascii' => 'US-ASCII',
|
||||
'iso_8859_1' => 'ISO-8859-1 (Latin-1, européen occidental)',
|
||||
'iso_8859_2' => 'ISO-8859-2 (Latin-2, européen central)',
|
||||
'iso_8859_3' => 'ISO-8859-3 (Latin-3, européen du Sud)',
|
||||
'iso_8859_4' => 'ISO-8859-4 (Latin-4, européen du Nord)',
|
||||
'iso_8859_5' => 'ISO-8859-5 (Latin, cyrillique)',
|
||||
'iso_8859_6' => 'ISO-8859-6 (Latin, arabe)',
|
||||
'iso_8859_7' => 'ISO-8859-7 (Latin, grec)',
|
||||
'iso_8859_8' => 'ISO-8859-8 (Latin, hébreu)',
|
||||
'iso_8859_0' => 'ISO-8859-9 (Latin-5, turc)',
|
||||
'iso_8859_10' => 'ISO-8859-10 (Latin-6, nordique)',
|
||||
'iso_8859_11' => 'ISO-8859-11 (Latin, thaï)',
|
||||
'iso_8859_13' => 'ISO-8859-13 (Latin-7, balte)',
|
||||
'iso_8859_14' => 'ISO-8859-14 (Latin-8, celtique)',
|
||||
'iso_8859_15' => 'ISO-8859-15 (Latin-9, européen occidental révisé avec le signe euro)',
|
||||
'windows_1251' => 'Windows-1251 (CP1251)',
|
||||
'windows_1252' => 'Windows-1252 (CP1252)'
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php namespace Backend\Models;
|
||||
|
||||
use Str;
|
||||
use Lang;
|
||||
use Model;
|
||||
use League\Csv\Reader as CsvReader;
|
||||
|
|
@ -190,14 +191,38 @@ abstract class ImportModel extends Model
|
|||
return $file->getLocalPath();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all available encodings values from the localization config
|
||||
* @return array
|
||||
*/
|
||||
public function getFormatEncodingOptions()
|
||||
{
|
||||
return Lang::get('backend::lang.import_export.encodings');
|
||||
$options = [
|
||||
'utf-8',
|
||||
'us-ascii',
|
||||
'iso-8859-1',
|
||||
'iso-8859-2',
|
||||
'iso-8859-3',
|
||||
'iso-8859-4',
|
||||
'iso-8859-5',
|
||||
'iso-8859-6',
|
||||
'iso-8859-7',
|
||||
'iso-8859-8',
|
||||
'iso-8859-0',
|
||||
'iso-8859-10',
|
||||
'iso-8859-11',
|
||||
'iso-8859-13',
|
||||
'iso-8859-14',
|
||||
'iso-8859-15',
|
||||
'Windows-1251',
|
||||
'Windows-1252'
|
||||
];
|
||||
|
||||
$translated = array_map(function($option){
|
||||
return Lang::get('backend::lang.import_export.encodings.'.Str::slug($option, '_'));
|
||||
}, $options);
|
||||
|
||||
return array_combine($options, $translated);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in New Issue