forked from mutoh/locale
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix wrong environment variable check
LC_CTYPES should be checked instead of LC_MESSAGES. Fix the third report of mutoh#5. Debian bug #520181: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=520181 Patch by Hleb Valoshka. Thanks!!! Rreported by Adeodato Simó. Thanks!!!
- Loading branch information
Showing
5 changed files
with
13 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2012 Kouhei Sutou <[email protected]> | ||
# Copyright (C) 2012 Hleb Valoshka | ||
# Copyright (C) 2008 Masao Mutoh | ||
# | ||
# Original: Ruby-GetText-Package-1.92.0. | ||
|
@@ -33,19 +34,19 @@ module Driver | |
module Env | ||
module_function | ||
|
||
# Gets the locale from environment variable. (LC_ALL > LC_MESSAGES > LANG) | ||
# Gets the locale from environment variable. (LC_ALL > LC_CTYPES > LANG) | ||
# Returns: the locale as Locale::Tag::Posix. | ||
def locale | ||
# At least one environment valiables should be set on *nix system. | ||
[ENV["LC_ALL"], ENV["LC_MESSAGES"], ENV["LANG"]].each do |loc| | ||
[ENV["LC_ALL"], ENV["LC_CTYPES"], ENV["LANG"]].each do |loc| | ||
if loc != nil and loc.size > 0 | ||
return Locale::Tag::Posix.parse(loc) | ||
end | ||
end | ||
nil | ||
end | ||
|
||
# Gets the locales from environment variables. (LANGUAGE > LC_ALL > LC_MESSAGES > LANG) | ||
# Gets the locales from environment variables. (LANGUAGE > LC_ALL > LC_CTYPES > LANG) | ||
# * Returns: an Array of the locale as Locale::Tag::Posix or nil. | ||
def locales | ||
locales = ENV["LANGUAGE"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2012 Kouhei Sutou <[email protected]> | ||
# Copyright (C) 2012 Hleb Valoshka | ||
# Copyright (C) 2009-2010 Masao Mutoh | ||
# | ||
# License: Ruby's or LGPL | ||
|
@@ -27,14 +28,14 @@ def setup | |
Locale.init | ||
Locale.clear_all | ||
ENV["LC_ALL"] = nil | ||
ENV["LC_MESSAGES"] = nil | ||
ENV["LC_CTYPES"] = nil | ||
ENV["LANG"] = nil | ||
ENV["LANGUAGE"] = nil | ||
end | ||
|
||
def test_lc_all | ||
ENV["LC_ALL"] = "ja_JP.eucJP" | ||
ENV["LC_MESSAGES"] = "zh_CN.UTF-8" #Ignored. | ||
ENV["LC_CTYPES"] = "zh_CN.UTF-8" #Ignored. | ||
ENV["LANG"] = "ko_KR.UTF-8" #Ignored. | ||
ENV["LANGUAGE"] = nil | ||
|
||
|
@@ -50,7 +51,7 @@ def test_lc_all | |
|
||
def test_lc_messages | ||
ENV["LC_ALL"] = nil | ||
ENV["LC_MESSAGES"] = "ja_JP.eucJP" | ||
ENV["LC_CTYPES"] = "ja_JP.eucJP" | ||
ENV["LANG"] = "ko_KR.UTF-8" #Ignored. | ||
ENV["LANGUAGE"] = nil | ||
|
||
|
@@ -66,7 +67,7 @@ def test_lc_messages | |
|
||
def test_lang | ||
ENV["LC_ALL"] = nil | ||
ENV["LC_MESSAGES"] = nil | ||
ENV["LC_CTYPES"] = nil | ||
ENV["LANG"] = "ja_JP.eucJP" | ||
ENV["LANGUAGE"] = nil | ||
|
||
|
@@ -82,7 +83,7 @@ def test_lang | |
|
||
def test_lang_complex | ||
ENV["LC_ALL"] = "zh_CN.UTF-8" # Ignored. | ||
ENV["LC_MESSAGES"] = "ko_KR.UTF-8" #Ingored. | ||
ENV["LC_CTYPES"] = "ko_KR.UTF-8" #Ingored. | ||
ENV["LANG"] = "en_US.UTF-8" # Ignored. | ||
ENV["LANGUAGE"] ="ja_JP.eucJP:zh_CN.UTF-8" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters