<commit_before>require 'merb_global/base'
require 'thread'
require 'weakref'

class Thread
  attr_accessor :mg_locale
end

module Merb
  module Global
    class Locale
      attr_reader :language, :country
      
      def initialize(name)
        # TODO: Understend RFC 1766 fully
        @language, @country = name.split('-')
      end

      def any?
        language == '*' && country.nil?\
      end

      def base_locale
        if not @country.nil?
          Locale.new(@language)
        else
          nil
        end
      end

      def to_s
        if country.nil?
          "#{@language.downcase}"
        else
          "#{@language.downcase}_#{@country.upcase}"
        end
      end<commit_msg>Added generating Java locale from the locale object<commit_after>require 'merb_global/base'
require 'thread'
require 'weakref'

class Thread
  attr_accessor :mg_locale
end

module Merb
  module Global
    class Locale
      attr_reader :language, :country

      def initialize(name)
        # TODO: Understend RFC 1766 fully
        @language, @country = name.split('-')
      end

      def any?
        language == '*' && country.nil?\
      end

      def base_locale
        if not @country.nil?
          Locale.new(@language)
        else
          nil
        end
      end

      def to_s
        if country.nil?
          "#{@language.downcase}"
        else
          "#{@language.downcase}_#{@country.upcase}"
        end
      end

      if defined? RUBY_ENGINE and RUBY_ENGINE == "jruby"
        def java_locale
          require 'java'
          @java_locale ||= do
            if @country.nil?
              java.util.Locale.new(@language.downcase)
            else
              java.util.Locale.new(@language.downcase, @country.upcase)
            end
          end
        end
      else
        def java_locale
          nil
        end
      end
{'fraction_non_alphanumeric': 0.08790623335109217, 'fraction_numerical': 0.004262120404901438, 'mean_word_length': 1.652542372881356, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '630995', 'n_tokens_mistral': 567, 'n_tokens_neox': 547, 'n_words': 143}