enchance
enchance

Reputation: 30411

Starting a multilingual site in Laravel

I'm about to create a multilingual site where English will be used for the public pages then Arabic for the Admin. I've never worked on this before and am unsure where to begin. Maybe those who've done multilingual sites before can answer a few questions for me.

  1. Can English and Arabic be saved in the same table? If so, my collation has always been utf-8 Unicode, does that mean I can't use utf8 any more?
  2. Will the Arabic portions of my site need its own table? If so, what collation?
  3. In my Views, what do I type in replacement for <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />?
  4. Is there anything I should know about starting a multilingual site?

I really am a bit lost on where to begin on this.

Upvotes: 5

Views: 6433

Answers (2)

moa101
moa101

Reputation: 11

By default, Laravel uses the email field for authentication. If you would like to customize this, you may define a username method on your LoginController:

public function username()
{
    return 'username';
}

Upvotes: 0

BenjaminRH
BenjaminRH

Reputation: 12172

  1. Yes, you can use utf8
  2. No, you can use both Arabic and English in the same table
  3. The Arabic charset is iso-8859-6, so you'll need to change the charset attribute in the admin views
  4. You probably want to use body { direction: rtl; } in your css for the Arabic pages

You might find these links useful:

When you want to validate form fields using Laravel's translation files (application/language/XX/validation.php), you will find that the :attribute placeholder uses the form field's name attribute, resulting in a mostly-translated error message with the word "email" (or whatever) in English. You can work around this by using the Validation Attributes array to hook up the English field names with the Arabic equivalent. If you find you've already translated them in another language file, you can use the following code instead:

'attributes' => array_merge(
    Lang::file('application', 'ar', 'filename_without_extension'),
    Lang::file('application', 'ar', 'another_file')
),

Upvotes: 6

Related Questions