Yii Framework Forum: yii2 Parameterizing Routes other languages - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

yii2 Parameterizing Routes other languages

#1 User is offline   TinweDeveloper 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 30-November 17

Posted 03 January 2018 - 04:59 PM

I have problem with routing i want use paramaterized route but i have url on polish format bt controllers , actions on english.

<?php 
/** example *//
<controller(konto)>/<action> => controller/action


But my controller is named AccountController and action in english but user will put it in polish version

How can i deal with this problem for get faster routing
0

#2 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,533
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 04 January 2018 - 12:42 AM

I don't think this should be problem you can map your polish routes/urls to english named controller/actions here for example

// you can map your polish to your specific english controller
<controller(konto)>/<action> => account/<action>
<controller(konto)>/<action(foo)> => account/foo

// explicit routes like this what I usually declare 
konto/foo => account/foo

0

#3 User is offline   TinweDeveloper 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 30-November 17

Posted 04 January 2018 - 04:24 AM

I want make flexible url rule not one rule match to one route.

'<controller:(konto)>/<action> => <controller>/<action>' 

0

#4 User is online   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 3,500
  • Joined: 16-February 11
  • Location:Japan

Posted 04 January 2018 - 05:47 AM

Internationalizing the routes might be an interesting challenge. Probably you have to write a dedicated URL manager which translates the English routes to the Polish ones when creating URLs, and translates back the Polish routes to the English ones when parsing URLs.

But, well, when you need only one language, for example, the Polish, I would consider naming the controllers and actions using the Polish words - "KontoController" for "AccountController", "actionAktualizacja" for "actonUpdate", ... etc.
1

#5 User is offline   TinweDeveloper 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 30-November 17

Posted 04 January 2018 - 06:04 AM

Thank you very much mate :)

I don't like mixing the english name classes with other language (not standard coding) but i think it's better for perfomance.

I thinking about it one week and i'm gonna make your solution and teeth bite for some polish name functions and class name. It will be very good for fast find route.

I really love this framework but i started coding with it last month (before laravel). It will be huge pros when you adding this internatolizaing urlmanager :)
0

#6 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,533
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 04 January 2018 - 06:18 AM

Well if that is the case you extend urlManager and add your functionality, there is a project authors do this but the routes are stored in mysql it called "Open Real Estate" they extended the urlManager to add this functionality look into that maybe it will give you a good starting point.

Its nice to hear you coming from laravel, nothing against laravel we love laravel, welcome to the forums.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users