Welcome Guest, Not a member yet? Register   Sign In
language go about question
#1

[eluser]Marc Arbour[/eluser]
Hi to all the community.

I am developping a website with proper language files like the way it should be. I can change my default language value in the config.php file and everything works fine.

This website can be accessed at CiĀ³.ca. I saw on my other website (working the exact same way with the exception of a language selector) that google doesn't index the french side.

Is there any way to transform this:
http://www.ci3.ca/index.php/example.html

into this:
http://www.ci3.ca/index.php/french/example.html
and this:
http://www.ci3.ca/index.php/english/example.html

so that the proper language file is taken automatically without changing the config.php or installing a language selector?

Any help would be appreciated.

Thank you in advance.
#2

[eluser]Michael Wales[/eluser]
You could use URI routing to direct the /language/controller/method requests to your currently configured controllers.

Within the controller - use $this->uri->segment(1) with your language loading methods to load the appropriate language.

You'll probably have to do some work on the URI class as well - if using the anchor() method - to ensure the language is carried over between links.

From an SEO standpoint - I would not move the english translation over to the /language/controller/method URL scheme - as Google has already started indexing your site using these URLs. I would leave english as the default (if not language has been selected) and then use your new scheme for any language other than english.
#3

[eluser]Marc Arbour[/eluser]
Thank you for that.

If I understand correctly (being an old type php coder and VERY new to the MCV scheme), I need to take possession of the first URI segment and tell the URI class that?

Usually, of what I understand, the 1st uri segment is a function to be called. I did try a couple of things already, but aside 404 and blank pages, I acheived nothing.

I made a full text search for segment(1) and found it hardcoded into the scafolding and databases files. So since it's hardcoded... I guess I should try using the 1 "always" available parameter which is URI segment 2.

would that be better?

my last idea would be to create 2 dirs at my httpdocs root, french and english... creating simlinks for all the files but for the config. Then I would have ci3.ca/french/index.php and ci3.ca/english/index.php That way, I don't have to hack the core or anything.
#4

[eluser]Marc Arbour[/eluser]
Ok, I got it.

simply created index_french and index_english in the httpdocs and changed values for $application_folder

It did the trick. It's not as elegant as I'd hoped, but it works. I just need to cron a job to sync my "copied" $application_folder every now and then in case I change something on the site.

Thanks
#5

[eluser]trailer123[/eluser]
All the best Mac. Keep up the good work.Smile
#6

[eluser]Marc Arbour[/eluser]
Ok. I polished my solution again.

It doesn't involve the creation of a second subdir.

I copied-pasted the index as said

I added
Code:
$language_index    = "english"; //allowed values are those for which you have language files properly installed in CI
at line 46 in both my index_french.php and index_english.php of the httpdocsroot

Then, I added
Code:
define('APP_LANGUAGE', $language_index);
at line 95.

And last, I changed, respectively, lines 26 and 40 for
Code:
$config['language']    = APP_LANGUAGE;
and
$config['index_page'] = "index_".$config['language'].".php";
in system/application/config/config.php

It works a charm.

Could anyone tell me if they foresee any problem with this solution and is it worth making a wiki with this.

Best regards.
#7

[eluser]Marc Arbour[/eluser]
This is "wiki'ed" here: http://codeigniter.com/wiki/allowing_sea..._langages/ for future references.




Theme © iAndrew 2016 - Forum software by © MyBB