Sha256: 8095414bfa1495601fcb59155a0e6ccd41a6450279febd171894934aa310b698

Contents?: true

Size: 954 Bytes

Versions: 1

Compression:

Stored size: 954 Bytes

Contents

class NSString
  def _localized(value=nil, table=nil)
    @localized = NSBundle.mainBundle.localizedStringForKey(self, value:value, table:table)
    store(self, @localized, value, table) if phraseEnabled?
    @localized
  end
  alias __ _localized

private
  def store(key, localized, defaultValue=nil, table=nil)
    @client = MotionPhrase::ApiClient.sharedClient
    @client.store(key, localized, defaultValue, currentLocaleName)
  end

  def phraseEnabled?
    PHRASEAPP_ENABLED == true && development?
  end

  def currentLocaleName
    currentLocale.localeIdentifier
  end

  # @return [NSLocale] locale of user settings
  def currentLocale
    languages = NSLocale.preferredLanguages
    if languages.count > 0
      return NSLocale.alloc.initWithLocaleIdentifier(languages.first)
    else
      return NSLocale.currentLocale
    end
  end

  def environment
    RUBYMOTION_ENV
  end

  def development?
    environment == 'development'
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phraseapp-rubymotion-1.0.0 lib/phraseapp-rubymotion/nsstring.rb