Part of the EllisLab Network
This thread is a discussion for the wiki article: URI Language Identifier
   
2 of 3
2
URI Language Identifier
Posted: 14 October 2008 06:10 AM   [ Ignore ]   [ # 16 ]  
Summer Student
Total Posts:  10
Joined  05-13-2008

Thanks smile It’s OK now.

Profile
 
 
Posted: 14 October 2008 09:29 AM   [ Ignore ]   [ # 17 ]  
Grad Student
Avatar
Rank
Total Posts:  58
Joined  05-08-2008

To get localized uri’s you have to define these per language.

$route["en/search"] = "engine/search";
$route["de/suchen"] = "engine/search";
$route["nl/zoeken"] = "engine/search";
$route["busca"] = "engine/search"; // <= default

//Standard
$route['default_controller'] = "default_controller";
$route['(\w{2})/(.*)'] = '$2';
$route['(\w{2})'] = $route['default_controller'];

I have adapted the URI Language Identifier to support cookies (for returning visitors), and auto determination of the starting language, depending on browser language and/or GeoIP. If you’re interested PM me.

Profile
 
 
Posted: 27 October 2008 01:28 PM   [ Ignore ]   [ # 18 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  393
Joined  05-29-2006

I have a routes as

$route['(\w{2})/(.*)'] = '$2';
$route['(\w{2})'] = $route['default_controller'];
$route['(\w{2})/prova/(.*)'] = "welcome/prova/$2";


$route['default_controller'] = "welcome";
$route['scaffolding_trigger'] = "";

But if i type a URL as

http://localhost:8888/CI17/it/prova

it not work…
if i type

http://localhost:8888/CI17/it/welcome/prova

all work…. why?

It is also possible to translate the language identifier as last segment? Thank you

 Signature 

CI Js_calendar plugin click

WYSIWYG with CI

Profile
 
 
Posted: 28 October 2008 04:23 AM   [ Ignore ]   [ # 19 ]  
Grad Student
Avatar
Rank
Total Posts:  58
Joined  05-08-2008

You need an additional route, something like:

$route['(\w{2})/(.*)'] = '$2';
$route['(\w{2})'] = $route['default_controller'];
$route['(\w{2})/prova/(.*)'] = "welcome/prova/$2";
$route['(\w{2})/prova'] = "welcome/prova";
Profile
 
 
Posted: 28 October 2008 05:08 AM   [ Ignore ]   [ # 20 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  393
Joined  05-29-2006

ok Thank you

 Signature 

CI Js_calendar plugin click

WYSIWYG with CI

Profile
 
 
Posted: 02 January 2009 06:02 PM   [ Ignore ]   [ # 21 ]  
Summer Student
Total Posts:  1
Joined  01-02-2009

Im using this extension on a new site and I while testing it I found the following:

The output for

<?php echo site_url(); ?><br />
<?php  echo uri_string(); ?><br />
<?php echo current_url(); ?><br />
<?php  echo base_url(); ?>

is:

http://192.168.1.3/bizart/new/en/
/en/home/index/test
http
://192.168.1.3/bizart/new/en/en/home/index/test
http://192.168.1.3/bizart/new/

Notice how ‘en’ appears 2 times on current_url() giving an incorrect url. I think it is because internally current_url is calculated by calling site_url(uri_string()) and as the ‘en’ appear in both they are duplicated. Shouldn’t uri_string() return the string without the language prefix? Or as another alternative have site_url() return without the prefix and let uri_string() return it? Don’t know which would be the most elegant solution.

Thanks in advance
M.

Profile
 
 
Posted: 05 January 2009 09:44 PM   [ Ignore ]   [ # 22 ]  
Grad Student
Avatar
Rank
Total Posts:  85
Joined  12-04-2008

I’m having the same problem as above. Any answers?

Profile
 
 
Posted: 06 January 2009 05:10 AM   [ Ignore ]   [ # 23 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  393
Joined  05-29-2006

override the current_url function for skip the first segment…..

 Signature 

CI Js_calendar plugin click

WYSIWYG with CI

Profile
 
 
Posted: 06 January 2009 06:00 AM   [ Ignore ]   [ # 24 ]  
Grad Student
Avatar
Rank
Total Posts:  85
Joined  12-04-2008
abmcr - 06 January 2009 05:10 AM

override the current_url function for skip the first segment…..

Not sure what you mean… Can you explain further…

Profile
 
 
Posted: 06 January 2009 06:26 AM   [ Ignore ]   [ # 25 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  393
Joined  05-29-2006

See in the user guide at http://codeigniter.com/user_guide/general/helpers.html
You need do extending the uri helper and add a current_uri function: in this function ignore the first segment…. Set (but i have not try)

function current_url()
    
{
        $CI
=& get_instance();
        return
$CI->config->base_url($CI->uri->uri_string());
    
}

Ciao

 Signature 

CI Js_calendar plugin click

WYSIWYG with CI

Profile
 
 
Posted: 06 January 2009 06:30 AM   [ Ignore ]   [ # 26 ]  
Grad Student
Avatar
Rank
Total Posts:  85
Joined  12-04-2008

Thanks for the tip… but is this a common problem with this script? Surely we could fix this without extending general functions?

Profile
 
 
Posted: 19 January 2009 01:29 AM   [ Ignore ]   [ # 27 ]  
Grad Student
Avatar
Rank
Total Posts:  85
Joined  12-04-2008

So no further responses here? Has this script never worked. I basically used it on a clean install and without modifying common system functions and it is pretty useless. I don’t like the idea of extending the uri helper to ignore the first segment because sometimes there is no language set in the uri and removing the first segment will cause the system to break.

Profile
 
 
Posted: 20 January 2009 01:23 PM   [ Ignore ]   [ # 28 ]  
Grad Student
Rank
Total Posts:  33
Joined  01-20-2009
Manuca - 02 January 2009 06:02 PM

Im using this extension on a new site and I while testing it I found the following:

The output for

<?php echo site_url(); ?><br />
<?php  echo uri_string(); ?><br />
<?php echo current_url(); ?><br />
<?php  echo base_url(); ?>

is:

http://192.168.1.3/bizart/new/en/
/en/home/index/test
http
://192.168.1.3/bizart/new/en/en/home/index/test
http://192.168.1.3/bizart/new/

Notice how ‘en’ appears 2 times on current_url() giving an incorrect url. I think it is because internally current_url is calculated by calling site_url(uri_string()) and as the ‘en’ appear in both they are duplicated. Shouldn’t uri_string() return the string without the language prefix? Or as another alternative have site_url() return without the prefix and let uri_string() return it? Don’t know which would be the most elegant solution.

Thanks in advance
M.

I have same problem :-( Please help how i can fix it….

Profile
 
 
Posted: 30 January 2009 05:53 AM   [ Ignore ]   [ # 29 ]  
Summer Student
Total Posts:  3
Joined  01-12-2009

I Use this library extension but I have a problem. When someone mistype his URL into something like http://domain.com/controlelr (with a error), I don’t get a 404 but a A PHP Error in this library because the controller was not found.

Is there a solution to throw a 404 page when the controller was not found?

Thanks for all !

Profile
 
 
Posted: 17 February 2009 07:14 PM   [ Ignore ]   [ # 30 ]  
Grad Student
Avatar
Rank
Total Posts:  80
Joined  06-06-2007

I tried to edit the Wiki page to fix the following line (41 of MY_url_helper.php) but the href in the code is stripped out.

The new code has spaces so remove them if you decide to use it.

Change from:

$alt_url .=>config->slash_item('base_url');

to

$alt_url .= ' < a href = " ' . $CI->config->slash_item(‘base_url’);

This may have been causing problems for someone, so it was time it was changed.

Cheers,

Mei

 Signature 

Web Development in north Wales
mei.gwilym.net

Profile
 
 
   
2 of 3
2
 
‹‹ Discussion Lists      Messages ››
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 77577 Total Logged-in Users: 21
Total Topics: 101563 Total Anonymous Users: 2
Total Replies: 544413 Total Guests: 194
Total Posts: 645976    
Members ( View Memberlist )