internationalization

Change locale at runtime in Rails 3

a 夏天 提交于 2020-01-23 03:21:10
问题 I am working on a rails 3 app which has different languages in my locales folder. The files are en.yml, pu.yml, sp.yml. All languages have to be converted to their various format and I need help in making users chose any language of their choice with a link like <%= link_to "English language", ...%> <%= link_to "spanish", ...%> When a user choses a language, the language is set as the user's preferred language so that the user does not have to keep selecting a language after each login. 回答1:

How to redirect users based on browser language

半世苍凉 提交于 2020-01-22 20:48:50
问题 I want to redirect users based on browser language, I figured out how to do this here, it works fine, here is the code(PHP): if(preg_match('/en-US/', $_SERVER['HTTP_USER_AGENT'])) header("location:index.php"); else header("location:http://cn.gearor.com"); The problem is I only want to redirect users from other websites or at the first visit to my website. Which means I don't want users reading some pages of my website, when they go back to index, they were redirect to other page. And I also

How to redirect users based on browser language

给你一囗甜甜゛ 提交于 2020-01-22 20:47:09
问题 I want to redirect users based on browser language, I figured out how to do this here, it works fine, here is the code(PHP): if(preg_match('/en-US/', $_SERVER['HTTP_USER_AGENT'])) header("location:index.php"); else header("location:http://cn.gearor.com"); The problem is I only want to redirect users from other websites or at the first visit to my website. Which means I don't want users reading some pages of my website, when they go back to index, they were redirect to other page. And I also

Japanese fonts in a Java GUI

妖精的绣舞 提交于 2020-01-22 18:53:05
问题 Is it possible to write a GUI in Java that would display Japanese fonts correctly regardless of the language settings of the OS it's being run on? I'd like to write a program which is able to do this but I'm not sure how to start going about this. Any advice would be a huge help! 回答1: The language settings aren't the problem here. Fonts are. Java certainly can handle Japanese text, no matter what the system settings are, if the developer doesn't fall into the trap of depending on the platform

how to have unicode characters in django url?

笑着哭i 提交于 2020-01-22 02:31:07
问题 My Url conf is as follows url(ur'^phrase/(?P<lang>[_A-Za-z]+)/(?P<phrase>[%A-Za-z0-9]+)/$', 'gs.langdb.views.phrases'), Views.phrases returns JSON object def phrases(request,lang,phrase): langs = Langauges.objects.all().values( 'language', 'lang_code') lang_list = [] try: map(lambda x: lang_list.append(x),langs) json = simplejson.dumps(lang_list) return HttpResponse(json, mimetype='application/json') except TypeError: print "Can't convert language to Json \n" My View is as follows:- $("

Php str_replace not working with special chars

与世无争的帅哥 提交于 2020-01-21 12:10:50
问题 why isn't this working as expected: echo str_replace("é","é","Fédération Camerounaise de Football"); result: "Fédération Camerounaise de Football" i'm expecting to have: "Fédération Camerounaise de Football" 回答1: You are doing it wrong. This string is not incorrect and in need of replacement, it is simply encoded with UTF-8. All you have to do is utf8_decode('Fédération Camerounaise de Football') . Update: You are seeing Fédération Camerounaise de Football as output because you are

Special and accented characters

十年热恋 提交于 2020-01-21 08:44:57
问题 I am doing some work for a French client and so need to deal with accented characters. But I'm running into a lot of difficulty, I am hoping the solution is simple and that somebody can point it out to me. The string: La Forêt pour Témoin is converted to: La For? pour T?oin Note the missing character following the accented character - the t following the ê and the m following the é . I have tried using StringEscapeUtils which was successful at escaping some characters, such as ă . I have also

Special and accented characters

守給你的承諾、 提交于 2020-01-21 08:43:18
问题 I am doing some work for a French client and so need to deal with accented characters. But I'm running into a lot of difficulty, I am hoping the solution is simple and that somebody can point it out to me. The string: La Forêt pour Témoin is converted to: La For? pour T?oin Note the missing character following the accented character - the t following the ê and the m following the é . I have tried using StringEscapeUtils which was successful at escaping some characters, such as ă . I have also

Angular internationalization (i18n) and *ngFor

为君一笑 提交于 2020-01-21 04:18:08
问题 I have a simple generic component in Angular which receives a list of strings and creates a radio group for these strings: @Component({ selector: 'radio-group', templateUrl: `<div *ngFor="let item of items"> <label for="input_{{item}}">{{item}}</label> <input type="radio" id="input_{{item}}" value="{{item}}" [formControl]="radioControl"> </div>`, styleUrls: ['./radio-group.component.scss'] }) export class RadioGroupComponent { @Input() items: string[]; @Input() radioControl: FormControl; } I

Greek and text-transform:uppercase

≯℡__Kan透↙ 提交于 2020-01-20 22:14:21
问题 I've written a web application that contains translations in several languages (one of them being Greek.) When displaying a certain translation on the title, the design rule was that the text is supposed to be uppercased, which in any other language in the world is fine, but when it comes to Greek, browsers don't know what to do with the accents (see this) so they display the wrong uppercased String. From that patch I've linked above, I've transformed it to Javascript, ran some use cases