0

I am creating a Laravel table for the languages. In my up function of my Migration class for languages I want to insert all the different languages (ISO).

I have one single row that is giving some headache; Arabic. I let you try to insert this string 'native_name' =>'العربية' into this PHP code in your favorite editor (I have tried in Visual Code, in Google Sheet and even here in StackOverflow)

\DB::table('languages')->insert('language_name' => 'Arabic', HOW TO INSERT native language here?? ,'639_1'=> 'ar', '639_1' => 'ar', '639_2_T' => 'ara', '639_2_B' => 'ara', '639_3' => 'ara + 30', '639_6' => '');

The field '639_1' is moved and 'العربية' is placed as a field... like this:

\DB::table('languages')->insert(['language_name' => 'Arabic', 'native_name' =>'العربية','639_1'=> 'ar', '639_1' => 'ar', '639_2_T' => 'ara', '639_2_B' => 'ara', '639_3' => 'ara + 30', '639_6' => '']);

Things like that:

\DB::table('languages')->insert(['language_name' => 'English', 'native_name' => 'English', '639_1' => 'en', '639_2_T' => 'eng', '639_2_B' => 'eng', '639_3' => 'eng', '639_6' => 'engs']);

works like a charm.

  • I had to update my row... not nice, so in two queries (plus set a default value to native_language) $id = \DB::table('languages')->insertGetId(['language_name' => 'Arabic', '639_1'=> 'ar', '639_1' => 'ar', '639_2_T' => 'ara', '639_2_B' => 'ara', '639_3' => 'ara + 30', '639_6' => '']); \DB::table('languages')->where('id',$id)->update(['native_name' =>'العربية']); – Dominique Delcourt Dec 23 '21 at 16:25

1 Answers1

0

I have found a way: Translate the Arabic word into UTF8. This one did the job: https://www.browserling.com/tools/utf8-encode العربية is translated into: \xd8\xa7\xd9\x84\xd8\xb9\xd8\xb1\xd8\xa8\xd9\x8a\xd8\xa9

Just have to use the UTF-8 translation.