Esempio n. 1
0
    // 	$arr  = array( 'Köpfe', 'Kypper', 'Kopfe' );
    // $coll = collator_create( 'en' );
    // collator_sort_with_sort_keys( $coll, $arr );
    // var_export( $arr );
    // die;
    // $s1 = 'Hello';
    $locale = 'zh';
    $en = collator_create('en');
    $coll = collator_create($locale);
    // $res  = collator_get_sort_key( $coll, $s1);
    // echo urlencode($res);
    App::setLocale($locale);
    $countries = Vinfo\Country::get()->lists('name')->toArray();
    // collator_sort_with_sort_keys ($coll, $countries);
    foreach ($countries as &$country) {
        $country = ['name' => $country, 'pinyin' => Overtrue\Pinyin\Pinyin::trans($country), 'en' => collator_get_sort_key($en, $country), 'coll' => collator_get_sort_key($coll, $country)];
    }
    $countries = new Illuminate\Support\Collection($countries);
    $countries = $countries->sortBy('coll');
    foreach ($countries as $country) {
        echo $country['pinyin'] . '<br>';
    }
    return ' ';
    dd($countries);
});
Route::get('/test/region-names', function () {
    die;
    $translations = RegionTranslation::with('region.country')->get();
    //->where('id', '>', 640)->limit(10)
    foreach ($translations as $translation) {
        $locale = str_replace('-', '_', $translation->locale);