I am using this multilanguage addon http://codeigniter.com/wiki/CodeIgniter_2.1_internationalization_i18n to make available my codeigniter sites in various idioms.
I have this php code with echo links to change the language
echo anchor($this->lang->switch_uri('en'),'English | ');
echo anchor($this->lang->switch_uri('es'),'Español | ');
echo anchor($this->lang->switch_uri('ro'),'Română');
It does the change with no problem, but it doesn't remember it. When I change page, from home to about, will go back to browser's language or Romanian if browser's language is not defined.
So, what could go wrong? What and how should I do to remember that choice?
You could simply change the choice by using the session:
$this->session->set_userdata('language', 'en');
See more details about using session data
Later refer to what the users choice is by calling:
$language = $this->session->userdata('language ');
Related
my Joomla have 3 language and I submit sitename for each language in language manager.
I used this to get sitename
$app = JFactory::getApplication();
$sitename = $app->getCfg('sitename');
but this code only give me sitename submitted on General Configuration.
how to get sitename in that language?
Another possible solution (tho not so elegant is to fetch it from database table #__languages, where sitename is stored):
$lang = JFactory::getLanguage();
$db = JFactory::getDBO();
$query = 'SELECT sitename FROM #__languages WHERE lang_code = "' . $lang->getTag() . '"';
$db->setQuery($query);
$sitename = $db->loadResult();
// If no sitename defined - show default sitename
if (!$sitename){
$app = JFactory::getApplication();
$sitename = $app->getCfg('sitename');
}
Try this,
In your case $sitename = $app->getCfg('sitename'); will not work bcoz you are using multi-language Joomla Site.
This option is only for get the values from global configuration.
You can try this,
You have multiple language files available each have a Proper site name consider the constant is SITE_NAME="Your site name";
Then you can simply get your site name like below.
JText::_('SITE_NAME');
Hope its helps..
This is an old post but I wanted to reply because the same process I will outline below is applicable in Joomla 2.5 as well as Joomla 3.x. It does not require any special editing or extensions.
This can easily be accomplished by using Joomla's built in features in the "Language manager". These steps also assume you already have a Multilingual Joomla site up and running. If you need instructions on how to do this you can refer to this link:
https://www.scribd.com/doc/82768844/Joomla-2-5-multi-language-website-without-using-3rd-extensions-in-10-steps
then use the steps outlined below to give your site a custom site name for each language.
The Link above is for Joomla 2.5 but the same steps outlined there can be applied to a Joomla 3.x site.
1) Log in to the administrator section of the site
2) Click on "Extensions"
3) From the Extensions dropdown menu choose "Language Manager"
4) Once in Language Manager you will see the installed languages and these options:
Installed - Site
Installed - Administrator
Content
Overrides
NOTE:
In Joomla 2.5 they will be listed in a row above the installed languages.
In Joomla 3.x they will be listed in a column to the left of the installed languages.
5) Now click on "Content"
6) The name of each language under the "Title" row will now be clickable. Click on the name of the language you want to set the "Custom Site Name" for.
7) Once you have clicked on the language name look for "Site Name". In Joomla 2.5 this will be on the right hand side. In Joomla 3.x this will be in a row above the options.
8) Once you click on Site Name you will see an option that reads "Custom Site Name". Enter the custom site name for that language and it will take priority, essentially overriding what is entered in the Global Configuration.
Please note also that you only need to enter a custom site name for the language that you want to change it for. Example: if your site's main language is English and you have the English version of your site name listed in the Global Configuration and you also have French, Spanish, and German installed then you only need to enter, if you want, a custom site name for the French, Spanish, and German languages.
Something else to consider is that if you need to add a custom site name for the language(s) you more than likely should consider adding custom Metadata for the language(s) such as the "Meta Keywords" and "Meta Description". To accomplish this follow the steps outlined above up to Step 5. Instead of clicking on Site Name you would click on Metadata and enter the language specific customized information for "Meta Keywords" and "Meta Description".
9) Last but not least, and most importantly, after you're all done with the language customizations, Click on "Save" or "Save & Close" to save all your changes.
This new language specific custom site name will be displayed if the site is offline.
Also, for SEO purposes, you can have your site name displayed either before or after the name of the Menu item which appears in the tabs.
That setting can be changed in the Global Configuration options.
Under SEO Settings look for "Include Site Name in Page Titles" and choose either "After", Before, or "No".
I've an website in dutch. http://www.domain.com and an german flag button to http://www.domain.com/german.
i have made an store view called german with a local language german.
How do i get to view this store view on the link www.domain.com/german
There are few ways for doing this.
1) Enable store code in the URL.
Magento allows you to add a store code of your store view to the URL. For instance, if your Dutch store view has a code dutch and your German store view has a code german, then Magento will automatically load a correct store. domain.com/dutch will load a Dutch version and domain.com/german will load the German version of your website. The drawback of this solution is a store code added even for the main domain.
The config setting can be found in Admin Panel (aka Back Office, BO) > System > Configuration > Web > Url Options. There you will find "Add Store Code to URLs" option.
2) Edit .htaccess file.
If you want to avoid the drawback of solution 1) you can modify your main .htaccess file. Add an entry that will search for /german suffix and will load the German store code. Here's a small example (I'm not an expert in this matter, but it should be something like this):
SetEnvIf Host .*domain.com/german.* MAGE_RUN_CODE="german"
You can play around with .htaccess more. Search the web if you want to learn more about .htaccess stuff.
3) Modify index.php of the application
This is very similar to the solution 2), but you do this directly in PHP. Find
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
line in index.php and replace it with something like this:
if (!$_SERVER['MAGE_RUN_CODE'] && strpos($_SERVER['HTTP_HOST'], '/german') !== false) {
$mageRunCode = 'german';
} else {
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
}
4) Add a new entry to the Apache vhost.
Create a new virtual host (vhost) for domain domain.com/german and put there SetEnv MAGE_RUN_CODE "german".
In my opinion the best option is the 2). It is the most flexible and you don't have to change any code. For development workstation 4) would be also sufficient.
Please note that these are only examples and they may not work on the first shot. I'm writing this from my memory and I cannot really check them now. Hope this gives you a brief idea how to handle your situation.
I have setup a multi lingual site using magento version 1.3.2.4 and have come accross some weird problems. Hoping that I could get some assistance.
The requirement was to add the new store view (dutch) and also maintain the current stores url structure, so I couldnt use 'Add store codes to urls' in the admin configuration as it would append the current urls with the default store code (fr). So, ultimately I needed the following url structures:
Default language (fr) url style : http://www.domainname.com
Dutch version url style : http://www.domainname.com/nl
For this I performed the the following steps:
I created a store view (code nl)
I created a folder by the name of nl
I copied the .htaccess and index.php from the main web root and pasted it in this folder
I modified the code as follows in index.php :
Mage::app()->getLocale()->setLocale('nl_NL');
$mageRunCode = 'Netherlands';
$mageRunType = 'store';
Mage::app()->setCurrentStore(1); // 1 being the nl store id
Mage::run($mageRunCode, $mageRunType);
When I launch the site, and goto http://www.domainname.com/nl the interface is in dutch as expected, but when I perform the following tasks I get redirected
back to the default language:
Login
Goto checkout/cart
Goto new user signup
Upon checking the view-source of the DOM I notice that some urls are pointing to the default language and not the nl language. For example the login form's action attribute is http://www.domain.com/customer/account/loginPost/ and not http://www.domain.com/nl/customer/account/loginPost/
Warm regards,
Hi instead of creating such a stuff .You can use this extension . Hope this help you and you can easily switch your language without creating a store view.
I got the same problem, cant have the same store code twice and when i try a new code it want link to the translation pack!
Is it possible to get session outside codeigniter application folder?
It is possible, but not without some work. You can see the details of someone else's problem and their solution in the CodeIgniter forum.
Basically you need take the cookie that CodeIgniter uses to handle it's sessions and unserialize it:
$sess = unserialize($_COOKIE['ci_session']);
You may need to also change settings in your application so that cookies are set for the entire domain, not just for the folder that CodeIgniter sits in.
Its a trick but do work. Place this little naughty code just before login redirect. And now you can use ci_session with php native session too ,have fun !
<?php
session_start();
echo $_SESSION['ci_session'] = $this->session->userdata['ci_session'];
?>
I have a joomla 1.5.21 website for a friend, he created a selling page for a program...and he wants to protect the page of the program , and send the password to everyone who purchases it.
So I've downloaded the contentPassword Plugin, and put the code : {password pass="123"} in the page I want protect.
When entering the page..the page asks me to enter password, but when I insert password, (123) it doesn't open the page.
My question is : is there someone whose familiar with this plugin? or is there any other better method that will save me more time?
thank you in advance
You could try Mighty Membership. It limits access to articles, modules, components etc. Users can pay for a subscription which will allow them access to a specific article. You can also limit the amount of times they can view the page, so once they've paid, they can view the page once to download the software then it will be restricted again.
I've just used this to make a basic subscription only video site and it's pretty good.
Sadly it's not free though.
I really don't like to install plugins if it's not necessary. In your case I would add to the beginning of the article the following php code:
<?php
$protect = $_GET['prot'];
if ($protect != 'xR5dL0Nj76H'){
//get out of here if you don't send the correct GET parameter...
header('Location: http://www.google.com/');
}
//echo "logged in successfully!";
?>
and of course you'll have to send the users to the article with the GET parameter: &prot=xR5dL0Nj76H (its equivalent to have a shared password to all the users - like you describe)