Add language method to OS::Mac.

This commit is contained in:
Markus Reiter 2016-09-09 00:11:43 +02:00
parent f37d004ab5
commit 0243e1f9a7
2 changed files with 12 additions and 0 deletions

View File

@ -41,6 +41,10 @@ module OS
version.to_sym
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
# whether the user has developer tools installed or not.
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