Browse Source

fix default lang redirection

nas 3 years ago
parent
commit
a6bad544a8
4 changed files with 8 additions and 5 deletions
  1. 1
    1
      CMakeLists.txt
  2. 1
    1
      src/master.cpp
  3. 4
    2
      src/wiki.cpp
  4. 2
    1
      src/wiki.h

+ 1
- 1
CMakeLists.txt View File

101
 #  Localization
101
 #  Localization
102
 
102
 
103
 
103
 
104
-set(LOCALES he ru pl)
104
+set(LOCALES he ru pl fr)
105
 
105
 
106
 set(MO_FILES)
106
 set(MO_FILES)
107
 set(UPDATE_PO_LIST)
107
 set(UPDATE_PO_LIST)

+ 1
- 1
src/master.cpp View File

120
 				lname=p->first;
120
 				lname=p->first;
121
 			}
121
 			}
122
 		}
122
 		}
123
-		languages[lname]=settings().get<std::string>("wikipp.script") +"/"+ p->first.str();
123
+		languages[lname]=settings().get<std::string>("wikipp.script") +"/"+ settings().get<std::string>("wikipp.language_default");
124
 	}
124
 	}
125
 	media=settings().get<std::string>("wikipp.media");
125
 	media=settings().get<std::string>("wikipp.media");
126
 	syntax_highlighter=settings().get("wikipp.syntax_highlighter","");
126
 	syntax_highlighter=settings().get("wikipp.syntax_highlighter","");

+ 4
- 2
src/wiki.cpp View File

24
 	for(cppcms::json::object::const_iterator p=langs.begin();p!=langs.end();++p) {
24
 	for(cppcms::json::object::const_iterator p=langs.begin();p!=langs.end();++p) {
25
 		lang_map[p->first]=p->second.str();
25
 		lang_map[p->first]=p->second.str();
26
 	}
26
 	}
27
+	this->language_default = settings().at("wikipp.language_default").str();
27
 }
28
 }
28
 
29
 
29
 std::string wiki::root(std::string l)
30
 std::string wiki::root(std::string l)
41
 	if(booster::regex_match(url,res,lang_regex)) {
42
 	if(booster::regex_match(url,res,lang_regex)) {
42
 		std::map<std::string,std::string>::const_iterator p = lang_map.find(std::string(res[1]));
43
 		std::map<std::string,std::string>::const_iterator p = lang_map.find(std::string(res[1]));
43
 		if(p==lang_map.end()) {
44
 		if(p==lang_map.end()) {
44
-			page.redirect();
45
+			locale_name = this->language_default ;
46
+			page.redirect( this->language_default );
45
 		}
47
 		}
46
 		else {
48
 		else {
47
 			locale_name = p->first;
49
 			locale_name = p->first;
51
 		}
53
 		}
52
 	}
54
 	}
53
 	else
55
 	else
54
-		page.redirect();
56
+		page.redirect( this->language_default );
55
 }
57
 }
56
 
58
 
57
 
59
 

+ 2
- 1
src/wiki.h View File

31
 	apps::options options;
31
 	apps::options options;
32
 	apps::users users;
32
 	apps::users users;
33
 	apps::index index;
33
 	apps::index index;
34
-
34
+	std::string language_default;
35
+  
35
 	std::string root(std::string locale_name="");
36
 	std::string root(std::string locale_name="");
36
 	bool set_locale(std::string);
37
 	bool set_locale(std::string);
37
 	void run(std::string lang,std::string url);
38
 	void run(std::string lang,std::string url);

Loading…
Cancel
Save