Merge pull request #897 from reitermarkus/os-language

Add language method to `OS::Mac`.
This commit is contained in:
Markus Reiter 2016-09-10 00:03:17 +02:00 committed by GitHub
commit 4fb691e175
2 changed files with 12 additions and 0 deletions

View File

@ -41,6 +41,10 @@ module OS
version.to_sym version.to_sym
end end
def language
@language ||= Utils.popen_read("defaults", "read", ".GlobalPreferences", "AppleLanguages").delete(" \n\"()").sub(/,.*/, "")
end
# Locates a (working) copy of install_name_tool, guaranteed to function # Locates a (working) copy of install_name_tool, guaranteed to function
# whether the user has developer tools installed or not. # whether the user has developer tools installed or not.
def install_name_tool def install_name_tool

View File

@ -0,0 +1,8 @@
require "testing_env"
require "os/mac"
class OSMacLanguageTests < Homebrew::TestCase
def test_language_format
assert_match %r{\A[a-z]{2}(-[A-Z]{2})?\Z}, OS::Mac.language
end
end