Multi language issue

Hello i’m trying to setup multi language to my personal website, however the procces is okay but “special” characters are not displayed, it’s about serbian language.

c::set('language.detect', true);
c::set('languages', array(
  array(
    'code'    => 'en',
    'name'    => 'English',
    'default' => true,
    'locale'  => 'en_US',
    'url'     => '/en',
  ),
  array(
    'code'    => 'rs',
    'name'    => 'Srpski',
    'locale'  => 'sr_RS',
    'url'     => '/rs',
  ),
));

Have you saved all files in UTF-8 encoding? Might be that your Serbian content files are saved in a different encoding.

1 Like

Well i guess i did, just opened and edited it with Notepad++, however when i try to add ‘custom’ localization it shows me errors…

c::set('languages', array(
  array(
    'code'    => 'en',
    'name'    => 'English',
    'default' => true,
    'url'     => '/en',
    'locale'  => array(
      LC_COLLATE  => 'en_US.utf8',
      LC_MONETARY => 'en_US.utf8',
      LC_NUMERIC  => 'en_US.utf8',
      LC_TIME     => 'en_US.utf8',
      LC_MESSAGES => 'en_US.utf8',
      LC_CTYPE    => 'en_US.utf8'
    ),
  ),
  array(
    'code'    => 'rs',
    'name'    => 'Srpski',
    'url'     => '/rs',
    'locale'  => array(
      LC_COLLATE  => 'sr_RS.utf8',
      LC_MONETARY => 'sr_RS.utf8',
      LC_NUMERIC  => 'sr_RS.utf8',
      LC_TIME     => 'sr_RS.utf8',
      LC_MESSAGES => 'sr_RS.utf8',
      LC_CTYPE    => 'sr_RS.utf8'
    ),
  ),
));

Which errors? :slight_smile:

Notice: Use of undefined constant LC_MESSAGES - assumed 'LC_MESSAGES' in C:\xampp\htdocs\news\site\config\config.php on line 42
Notice: Use of undefined constant LC_MESSAGES - assumed 'LC_MESSAGES' in C:\xampp\htdocs\news\site\config\config.php on line 55
Warning: setlocale(): Invalid locale category name LC_MESSAGES, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, or LC_TIME in C:\xampp\htdocs\news\kirby\kirby.php on line 530

And by the way when i directly enter special character into (for example site\templates\default.php) it does display special character…

Could you just try this:

c::set('languages', array(
  array(
    'code'    => 'en',
    'name'    => 'English',
    'default' => true,
    'url'     => '/en',
    'locale'  => array(
      LC_ALL  => 'en_US.utf8',
    ),
  ),
  array(
    'code'    => 'rs',
    'name'    => 'Srpski',
    'url'     => '/rs',
    'locale'  => array(
      LC_ALL  => 'sr_RS.utf8',
  ),
));

Also double-check your files are saved as UTF8 by doing the following in notepad++:
Try Settings -> Preferences -> tab New document/Default Directory -> Encoding -> check UTF-8 without BOM, Apply to opened ANSI files.

1 Like

Well done, not displaying any errors, but it still didnt work

So what is not working now?
Can you show us?

Oh, i’m sorry it is working my bad, thanks for help :slight_smile::slight_smile:

1 Like