locale

Encoding Problems when running an app in docker (Python, Java, Ruby, …) with Ubuntu Containers (ascii, utf-8)

岁酱吖の 提交于 2019-12-18 11:46:09
问题 On my own PC the application runs nice, but when it gets deployed into docker, it fails because of invalid characters. I am using the ubuntu:lastest container and python3 , java and ruby . 回答1: You need to set the locale correct. This is the minimal correct Dockerfile: FROM ubuntu:latest RUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8 The usual docker images don't specify a locales. You see it if you bash into it and execute locale : sudo docker

Combine file modified date and “grep” results through “find”, in one line

泄露秘密 提交于 2019-12-18 09:23:43
问题 We want to show each file's modified date and time when applying grep to selected files by the find command. The final result should look like: 2016-10-17 Mon 20:38:57 ./rest/47results.php: 5 :σχόλια, ιδέες facebook Running the following from 47test.php file: system('export TZ=":Europe/Athens"; find . -name "*.*" \ -not \( -path ./admin -prune \) \ -not \( -path ./people/languages -prune \) \ -not \( -path ./include -prune \) \ -type f -mmin -10 \ -printf "%TY-%Tm-%Td %Ta %TH:%TM:%TS %p\n" \

In a WordPress plugin admin ajax call, which is the way of using the site's locale?

℡╲_俬逩灬. 提交于 2019-12-18 08:46:20
问题 After upgrading to WordPress 4.7, I changed the language field from my profile to english, while the site's language is set to greek. I have written a plugin that displays a widget. This widget is refreshing its content via an ajax call. As it is mentioned here (see Note about admin-ajax.php ), strings are normally returned in my profile's language (english), but I would prefer to have them in the site's locale (greek). After adding the statement switch_to_locale( get_locale() ) at the first

How to display locale sensitive time format without seconds in python

允我心安 提交于 2019-12-18 07:36:12
问题 I can output a locale sensitive time format using strftime('%X') , but this always includes seconds. How might I display this time format without seconds? >>> import locale >>> import datetime >>> locale.setlocale(locale.LC_ALL, 'en_IE.utf-8') 'en_IE.utf-8' >>> print datetime.datetime.now().strftime('%X') 12:22:43 >>> locale.setlocale(locale.LC_ALL, 'zh_TW.utf-8') 'zh_TW.utf-8' >>> print datetime.datetime.now().strftime('%X') 12時22分58秒 The only way I can think of doing this is attempting to

Set locale via code in Struts2

五迷三道 提交于 2019-12-18 07:25:09
问题 In my application, I have to display the content based on the locale user chosen in the configuration page. I am not using browser default locale. when using s:text , it always use the default resource file. In Struts1, I have used the below code to set default locale in my filter session.setAttribute("org.apache.struts.action.LOCALE",locale); How to set the user chosen locale dynamically in Struts2 ? 回答1: This worked for me : String language = userLocale.substring(0, 2); String country =

Python parsing date and find the correct locale_setting

做~自己de王妃 提交于 2019-12-18 07:19:13
问题 I have the following date string: '3 févr. 2015 14:26:00 CET' datetime.datetime.strptime('03 févr. 2015 14:26:00', '%d %b %Y %H:%M:%S') Parsing this failed with the error: ValueError: time data '03 f\xc3\xa9vr. 2015 14:26:00' does not match format '%d %b %Y %H:%M:%S' I tried to loop over all locales with locale.locale_alias : for l in locale.locale_alias: try: locale.setlocale(locale.LC_TIME, l) print l,datetime.datetime.strptime('03 févr. 2015 14:26:00', '%d %b %Y %H:%M:%S') break except

Python parsing date and find the correct locale_setting

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 07:18:04
问题 I have the following date string: '3 févr. 2015 14:26:00 CET' datetime.datetime.strptime('03 févr. 2015 14:26:00', '%d %b %Y %H:%M:%S') Parsing this failed with the error: ValueError: time data '03 f\xc3\xa9vr. 2015 14:26:00' does not match format '%d %b %Y %H:%M:%S' I tried to loop over all locales with locale.locale_alias : for l in locale.locale_alias: try: locale.setlocale(locale.LC_TIME, l) print l,datetime.datetime.strptime('03 févr. 2015 14:26:00', '%d %b %Y %H:%M:%S') break except

How to determine which day is the first in week in current locale in C

送分小仙女□ 提交于 2019-12-18 07:07:34
问题 How to determine which day is the first in week in current locale in C. In Russia monday is the first day, but my mac shows localized calendar with wrong first day. So i wonder if i can determine which day is the first in current locale. Thanks. anatoly@mb:/Users/anatoly$ cal Июля 2012 вс пн вт ср чт пт сб 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 回答1: I was wrong in my first post, and ICU provides a C API. So, if dependency on that library is

Device vs. Simulator Linguistic Schemes

时光总嘲笑我的痴心妄想 提交于 2019-12-18 06:20:51
问题 Does anyone understand why this is happening? On any simulator all of the schemes are found with the following code: NSArray<NSLinguisticTagScheme> *availSchemes = [NSLinguisticTagger availableTagSchemesForLanguage:@"en"]; for (NSLinguisticTagScheme scheme in availSchemes) { NSLog(@"Tag scheme %@", scheme); } yielding the following: 2018-02-13 09:12:54.066970-0500 MY_APP[79671:5737063] Tag scheme Language 2018-02-13 09:12:54.067160-0500 MY_APP[79671:5737063] Tag scheme Script 2018-02-13 09:12

Device vs. Simulator Linguistic Schemes

狂风中的少年 提交于 2019-12-18 06:20:02
问题 Does anyone understand why this is happening? On any simulator all of the schemes are found with the following code: NSArray<NSLinguisticTagScheme> *availSchemes = [NSLinguisticTagger availableTagSchemesForLanguage:@"en"]; for (NSLinguisticTagScheme scheme in availSchemes) { NSLog(@"Tag scheme %@", scheme); } yielding the following: 2018-02-13 09:12:54.066970-0500 MY_APP[79671:5737063] Tag scheme Language 2018-02-13 09:12:54.067160-0500 MY_APP[79671:5737063] Tag scheme Script 2018-02-13 09:12