0

I have developed a small project using phalcon, in which the default language is japanese, but now the requirement is like a user should manually select either english or japanese language by clicking any of these two links from the homepage. How to have another language for the same project and is there any way to implement this, I am a newbie in phalcon. can anyone please help me step by step how to do this. Thanks in advance.

galki
  • 8,149
  • 7
  • 50
  • 62
MidhunKrishna
  • 611
  • 7
  • 18

1 Answers1

1

Use the router:

// Matches "/es/news"
$router->add(
    "/{language:[a-z]{2}}/:controller",
    array(
        "controller" => 2,
        "action"     => "index"
    )
);

Source: https://docs.phalconphp.com/en/latest/reference/routing.html#usage-examples

Or you can use sessions to save the selected language. On clicking the link you set the session language variable to the selected value, and then you can read the session in the method where you are generating the translation component.

Here is the documentation for the multi-lingual component: https://docs.phalconphp.com/en/latest/reference/translate.html

Dávid Szabó
  • 2,235
  • 2
  • 14
  • 26