Is language switch on Mysidia script possible?

Forum
Last Post
Threads / Messages

LUC1G07CH1

I'm a Unicorn
Member
Joined
Mar 31, 2016
Messages
114
Points
16
Age
21
Location
Brazil
Mysidian Dollar
11,813
Because i want to make my sites switchable to portuguese/english but it still has the same server.
Also...because portuguese is my native language and what if a friend of mine wants to access the site and they doesn't understand english after all? Or some random brazilian that also doesn't understand english wants to go on my site?

And because why not?
 
I haven't tried it, but here's my guess:
1. Create a new column in users_options where the preferred language is stored. You could also set the default value to 'english' or 'portuguese'. (Preferably use acronyms like 'en' or 'pr' to avoid any spelling errors that may come up later on while coding)
2. Go into the lang files and copy-paste all the lines, then change them to portuguese. (So keep all the english lines and underneath it have the portuguese lines!) Like this:
PHP:
$lang['title'] = "Welcome to Pound Center";
//the rest of the english lines

$lang['title_pr'] = "Bem-vindo ao Pound Center";
//the rest of the portuguese lines
(I used google translate, forgive me xD) Then in the view files you can do this:
PHP:
$language = $mysidia->db->select("users_options", array("language"), "username = '{$mysidia->user->username}'")->fetchColumn();
if($language == 'en'){
$document->addLangvar($this->lang->title);
}
else{
$document->addLangvar($this->lang->title_pr);
}

This isn't very in-depth, it's just the main idea. Let me know if you need more direction though!

EDIT: Removed the first option since the second was much cleaner.
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,278
Messages
33,125
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top