Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8110665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:50:05+00:00 2026-06-06T01:50:05+00:00

I am using language prefix in my app: Router::connect(‘/:language/:controller/:action/*’, array(), array(‘language’ => ‘[a-z]{3}’)); When

  • 0

I am using language prefix in my app:

Router::connect('/:language/:controller/:action/*',
                       array(),
                       array('language' => '[a-z]{3}'));

When I use $this->Html->link('title',$url_array) I have to set the language prefix manually.
And what I want is when the prefix is present in current url then when I use ->link(...) it should add this prefix automaticly to url. Only when I set this prefix explicite then it should be different.

Is it possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:50:07+00:00Added an answer on June 6, 2026 at 1:50 am

    If you want to manage your locale application wide (not per user) you should check what the current locale setting is in the URL in your AppController’s beforeFilter(). The :language prefix in your Router will ensure that you provide unique URLs for differently localized content.

    $this->Html->link() will act as you expect if the Config.language configuration setting is managed in the right manner.

    So in your AppController::beforeFilter() make an if() statement to detect which locale is being requested and depending on that do:

    Configure::write('Config.language', 'fre');
    

    or

    Configure::write('Config.language', 'eng');
    

    Doing this will ensure that both I18n and TranslateBehavior access the same language value.

    If you would like to manage application locale per user you can store the current locale in the Session:

    class AppController extends Controller {
        public function beforeFilter() {
            Configure::write('Config.language', $this->Session->read('Config.language'));
        }
    }
    

    Of course you should also use the Translation Function __(). Check out the Internationalization and Localization section of the Cake Book.
    Oh yeah, there is also something very important which is mentioned in the “fine print” of that article:

    There’s one other aspect of localizing your application which is not covered by the use of the translate functions, and that is date/money formats. Don’t forget that CakePHP is PHP :), therefore to set the formats for these things you need to use setlocale.
    If you pass a locale that doesn’t exist on your computer to setlocale it will have no effect. You can find the list of available locales by running the command locale -a in a terminal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this JavaScript tabbed script: http://net.tutsplus.com/tutorials/html-css-techniques/how-to-create-a-slick-tabbed-content-area/comment-page-2/#comments I have it working 100% if I'm
I want to connect to oracle database using C language in Windows OS. But
I'm attempting to use C# as a scripting language using CSharpCodeProvider (using VS2010 and
I'm using language files to allow users to switch between English and Dutch. The
I started using LINQ (Language Integrated Query) when it was still in beta, more
I'm using script language ChaiScript with c++ and Qt. I've defined such function: void
I am using netbeans and am using a language which is new and not
When using english the following URL should apply: http://example.org/services/myservice/ When using another language, the
I'm creating xml-like mark-up language using System.Xml.XmTextWriter that will be read by a third
I have to make a graphical user interface application using the language of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.