-
Notifications
You must be signed in to change notification settings - Fork 671
[#2064] Multilangual routes files support #1012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.4.x
Are you sure you want to change the base?
Changes from 1 commit
53d8547
8067cc2
899fc56
8cb5410
1387458
c21cdf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,7 @@ public boolean isProd() { | |
| /** | ||
| * Main routes file | ||
| */ | ||
| public static VirtualFile routes; | ||
| public static List<VirtualFile> routes; | ||
| /** | ||
| * Plugin routes files | ||
| */ | ||
|
|
@@ -182,6 +182,11 @@ public boolean isProd() { | |
| */ | ||
| public static boolean standalonePlayServer = true; | ||
|
|
||
| /** | ||
| * This flag indicates that app has multiple routes files for different locales | ||
| */ | ||
| public static boolean multilangRouteFiles = false; | ||
|
|
||
| /** | ||
| * Init the framework | ||
| * | ||
|
|
@@ -276,7 +281,7 @@ public static void init(File root, String id) { | |
| } | ||
|
|
||
| // Main route file | ||
| routes = appRoot.child("conf/routes"); | ||
| routes = loadRoutesFiles(appRoot); | ||
|
|
||
| // Plugin route files | ||
| modulesRoutes = new HashMap<>(16); | ||
|
|
@@ -321,6 +326,20 @@ public static void init(File root, String id) { | |
| Play.initialized = true; | ||
| } | ||
|
|
||
| private static List<VirtualFile> loadRoutesFiles(VirtualFile appRoot) { | ||
| List<VirtualFile> routes = new ArrayList<VirtualFile>(); | ||
| for (VirtualFile vf: appRoot.child("conf").list()) { | ||
| String virtualFileName = vf.getName(); | ||
| if(virtualFileName !=null && virtualFileName.equals("routes")){ | ||
| routes.add(vf); | ||
| } else if(virtualFileName !=null && virtualFileName.matches("routes\\.[A-Za-z]{2}")){ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. language can be defined on mode character to handle country specific code ex: en_US, en_UK
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xael-fry So routes files can have also names like that routes.en_US ? |
||
| routes.add(vf); | ||
| Play.multilangRouteFiles = true; | ||
| } | ||
| } | ||
| return routes; | ||
| } | ||
|
|
||
| public static void guessFrameworkPath() { | ||
| // Guess the framework path | ||
| try { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It breaks backward compatibility.
I suggest leaving
VirtualFile routesuntouched and adding a new fieldList<VirtualFile> internationalizedRoutes. In this case you don't need fieldmultilangRouteFiles.