Package er.extensions.localization

Examples of er.extensions.localization.ERXLocalizer


    public Object valueInObject(Object object) {
      ERXGenericRecord eo = (ERXGenericRecord) object;
      String localizedKey = eo.localizedKey(_key);
      Object value = eo.valueForKey(localizedKey);
      if (localizedKey != null && (value == null || "".equals(value)) && localizationShouldFallbackToDefaultLanguage()) {
        ERXLocalizer currentLocalizer = ERXLocalizer.currentLocalizer();
        String defaultLanguage = ERXLocalizer.defaultLanguage();
        if (!currentLocalizer.language().equals(defaultLanguage)) {
          if (log.isDebugEnabled()) {
            log.debug("no data found for '" + eo.entityName() + ':' + _key + "' for language " + currentLocalizer.language() + ", trying " + defaultLanguage);
          }
          ERXLocalizer.setCurrentLocalizer(ERXLocalizer.localizerForLanguage(defaultLanguage));
          value = eo.valueForKey(eo.localizedKey(_key));
          ERXLocalizer.setCurrentLocalizer(currentLocalizer);
        }
View Full Code Here


      return Integer.valueOf(new GregorianCalendar(locale()).getFirstDayOfWeek() - 1);
    }
   
    private NSArray<String> localizeStringArray(NSArray<String> strings) {
      NSMutableArray<String> localizedStrings = new NSMutableArray<String>(strings.count());
      ERXLocalizer l = ERXLocalizer.currentLocalizer();
      for (String string : strings)
        localizedStrings.add(l.localizedStringForKeyWithDefault(string));
      return localizedStrings.immutableClone();
    }
View Full Code Here

   
    public static void initialize() {
        if(initialized)
            return;
        initialized = true;
        ERXLocalizer l = ERXLocalizer.localizerForLanguage("English");
        jode.GlobalOptions.err = new PrintWriter(new StringWriter());
        documentationPaths = (NSMutableArray)l.valueForKey("DocumentationPaths");

        NSArray arr = (NSArray)l.valueForKey("ClassPaths");
        cp = arr.componentsJoinedByString(":");
        ClassInfo.setClassPath(cp);
        arr = (NSArray)l.valueForKey("PackagesToIndex");
        for(Enumeration e = arr.objectEnumerator(); e.hasMoreElements();) {
            PackageProxy.indexPackage((String)e.nextElement(), null, true);
        }
    }
View Full Code Here

  private NSDictionary<String, String> displayStringForLanguages() {
    if (displayStringForLanguages == null) {
      NSMutableDictionary<String, String> displayStrings = new NSMutableDictionary<String, String>();
      for (Object o : availableLanguages()) {
        String languageKey = (String) o;
        ERXLocalizer loc = ERXLocalizer.localizerForLanguage(languageKey);
        String displayString = loc.localizedStringForKey(languageKey);
        if (ERXStringUtilities.stringIsNullOrEmpty(displayString)) {
          displayString = languageKey;
        }
        displayStrings.put(languageKey, displayString);
      }
View Full Code Here

     * localize "entityName.key" then "key" if nothing found.
     * @param key to be translated
     * @return localized display version of the given key.
     */
    protected String localizedDisplayNameForKey(String key) {
        ERXLocalizer localizer = null;
       
        if (targetLanguage() != null) {
            localizer = ERXLocalizer.localizerForLanguage(targetLanguage());
        } else {
          localizer = ERXLocalizer.currentLocalizer();
View Full Code Here

        return localizer().plurifiedString(value, c!=null ? c.intValue() : 0);
    }

    @Override
    public ERXLocalizer localizer() {
        ERXLocalizer l=(ERXLocalizer)valueForBinding("localizer");
        return l!=null ? l : ERXLocalizer.currentLocalizer();
    }
View Full Code Here

   * @param language to set the current localizer for.
   * @see #language
   * @see #setLanguages
   */
  public void setLanguage(String language) {
    ERXLocalizer newLocalizer = ERXLocalizer.localizerForLanguage(language);
    if (!newLocalizer.equals(_localizer)) {
      if (_localizer == null && !WOApplication.application().isCachingEnabled())
        observer().registerForLocalizationDidResetNotification();

      _localizer = newLocalizer;
      ERXLocalizer.setCurrentLocalizer(_localizer);
View Full Code Here

   * @see #setLanguage
   */
  @Override
  public void setLanguages(NSArray languageList) {
    super.setLanguages(languageList);
    ERXLocalizer newLocalizer = ERXLocalizer.localizerForLanguages(languageList);
    if (!newLocalizer.equals(_localizer)) {
      if (_localizer == null && !WOApplication.application().isCachingEnabled())
        observer().registerForLocalizationDidResetNotification();

      _localizer = newLocalizer;
      ERXLocalizer.setCurrentLocalizer(_localizer);
View Full Code Here

   * @return shared instance of formatter
   */
  public static NSTimestampFormatter dateFormatterForPattern(String pattern) {
    NSTimestampFormatter formatter;
    if(ERXLocalizer.useLocalizedFormatters()) {
      ERXLocalizer localizer = ERXLocalizer.currentLocalizer();
      formatter = (NSTimestampFormatter)localizer.localizedDateFormatForKey(pattern);
    } else {
      synchronized(_repository) {
        formatter = (NSTimestampFormatter)_repository.get(pattern);
        if(formatter == null) {
          formatter = new NSTimestampFormatter(pattern);
View Full Code Here

  /**
   * Sets a shared instance for the specified pattern.
   */
  public static void setDateFormatterForPattern(NSTimestampFormatter formatter, String pattern) {
    if(ERXLocalizer.useLocalizedFormatters()) {
      ERXLocalizer localizer = ERXLocalizer.currentLocalizer();
      localizer.setLocalizedDateFormatForKey(formatter, pattern);
    } else {
      synchronized(_repository) {
        if(formatter == null) {
          _repository.remove(pattern);
        } else {
View Full Code Here

TOP

Related Classes of er.extensions.localization.ERXLocalizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.