~tetradice1011/rumix/m17n

« back to all changes in this revision

Viewing changes to lib/locale/driver/jruby.rb

  • Committer: Dice
  • Date: 2009-05-10 11:24:59 UTC
  • Revision ID: tetradice+lp@gmail.com-20090510112459-8mtni5270r3n5a5d
create base for m17n

(多言語化のための基本的な環境を整えた)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
=begin
 
2
  locale/driver/jruby.rb
 
3
 
 
4
  Copyright (C) 2007,2008 Masao Mutoh
 
5
 
 
6
  You may redistribute it and/or modify it under the same
 
7
  license terms as Ruby.
 
8
 
 
9
  Original: Ruby-GetText-Package-1.92.0.
 
10
 
 
11
  $Id: jruby.rb 27 2008-12-03 15:06:50Z mutoh $
 
12
=end
 
13
 
 
14
require File.join(File.dirname(__FILE__), 'env')
 
15
require 'java'
 
16
 
 
17
module Locale
 
18
  module Driver
 
19
    # Locale::Driver::JRuby module for JRuby
 
20
    # Detect the user locales and the charset.
 
21
    # This is a low-level class. Application shouldn't use this directly.
 
22
    module JRuby
 
23
      $stderr.puts self.name + " is loaded." if $DEBUG
 
24
 
 
25
      if java.lang.System.getProperties['os.name'].downcase =~ /windows/
 
26
        require 'locale/driver/win32_table'
 
27
        
 
28
        extend ::Locale::Driver::Win32Table
 
29
      end
 
30
      
 
31
      module_function
 
32
      def locales  #:nodoc:
 
33
        locales = ::Locale::Driver::Env.locales
 
34
        unless locales
 
35
          locale = java.util.Locale.getDefault
 
36
          variant = Locale.getVariant 
 
37
          variants = []
 
38
          if valiant != nil and variant.size > 0
 
39
            valiants = [valiant]
 
40
          end
 
41
          locales = TagList.new([Locale::Tag::Common.new(locale.getLanguage, nil,
 
42
                                                         locale.getCountry, 
 
43
                                                         variants)])
 
44
        end
 
45
        locales
 
46
      end
 
47
 
 
48
      def charset
 
49
        charset = ::Locale::Driver::Env.charset
 
50
        unless charset
 
51
          charset = java.nio.charset.Charset.defaultCharset.name
 
52
        end
 
53
        charset
 
54
      end
 
55
    end
 
56
  end
 
57
  @@locale_driver_module = Driver::JRuby
 
58
end