Welcome Guest, Not a member yet? Register   Sign In
Multicountry - multilanguage website
#1

Hi everyone,

I need to develop a multicountry site, where the user can change language by selecting a country.
All countries have just one language assigned to them and multiple countries can have the same language.
Both country and language will always be in the url, after the domain (examples below):

www.domain.tld/uk/en/my-url

www.domain.tld/fr/fr/my-url
www.domain.tld/be/fr/my-url

By following the official documentation, I managed to get a working multilanguage site (using the files in the "Language" folder, which I'll use to set the translations), but I don't know how to relate countries with languages.

What is the best approach to this issue?

Thanks!
Reply
#2

@Deno

Which version of CI are you using? 3.x or 4.x?
Reply
#3

Sorry I forgot to mention, I am using CI 4.x. Smile
Reply
#4

first go there
https://codeigniter.com/user_guide/outgo...anslations

PHP Code:
then go app /config

/**
* --------------------------------------------------------------------------
* Default Locale
* --------------------------------------------------------------------------
*
* The Locale roughly represents the language and location that your visitor
* is viewing the site from. It affects the language strings and other
* strings (like currency markers, numbers, etc), that your program
* should run under for this request.
*
* @var string
*/
public $defaultLocale 'en';

/**
* --------------------------------------------------------------------------
* Negotiate Locale
* --------------------------------------------------------------------------
*
* If true, the current Request object will automatically determine the
* language to use based on the value of the Accept-Language header.
*
* If false, no automatic detection will be performed.
*
* @var boolean
*/
public $negotiateLocale true;

/**
* --------------------------------------------------------------------------
* Supported Locales
* --------------------------------------------------------------------------
*
* If $negotiateLocale is true, this array lists the locales supported
* by the application in descending order of priority. If no match is
* found, the first locale will be used.
*
* @var string[]
*/
public $supportedLocales = ['en','fa']; 
Accept-Language

finally send header  Accept-Language = en or fa
Enlightenment  Is  Freedom
Reply
#5

(06-14-2021, 12:22 PM)paliz Wrote: first go there
https://codeigniter.com/user_guide/outgo...anslations

PHP Code:
then go app /config

/**
* --------------------------------------------------------------------------
* Default Locale
* --------------------------------------------------------------------------
*
* The Locale roughly represents the language and location that your visitor
* is viewing the site from. It affects the language strings and other
* strings (like currency markers, numbers, etc), that your program
* should run under for this request.
*
* @var string
*/
public $defaultLocale 'en';

/**
* --------------------------------------------------------------------------
* Negotiate Locale
* --------------------------------------------------------------------------
*
* If true, the current Request object will automatically determine the
* language to use based on the value of the Accept-Language header.
*
* If false, no automatic detection will be performed.
*
* @var boolean
*/
public $negotiateLocale true;

/**
* --------------------------------------------------------------------------
* Supported Locales
* --------------------------------------------------------------------------
*
* If $negotiateLocale is true, this array lists the locales supported
* by the application in descending order of priority. If no match is
* found, the first locale will be used.
*
* @var string[]
*/
public $supportedLocales = ['en','fa']; 
Accept-Language

finally send header  Accept-Language = en or fa
Hi @paliz,

Thank you for your answer, unfortunately I already did these steps.
I already have a working multilanguage site, but I also need to implement the country feature.

Any suggestion?

Thanks Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB