Reads lang_xx.properties into field {@link #langs langs}.
193705
public void readLangs() {
        final ServletContext servletContext = AbstractServletListener.getServletContext();

        @SuppressWarnings("unchecked") final Set<String> resourcePaths = servletContext.getResourcePaths("/plugins/" + dirName);

        for (final String resourcePath : resourcePaths) {
            if (resourcePath.contains("lang_") && resourcePath.endsWith(".properties")) {
                final String langFileName = StringUtils.substringAfter(resourcePath, "/plugins/" + dirName + "/");

                final String key = langFileName.substring("lang_".length(), langFileName.lastIndexOf("."));
                final Properties props = new Properties();

                try {
                    final File file = Latkes.getWebFile(resourcePath);

                    props.load(new FileInputStream(file));

                    langs.put(key, props);
                } catch (final Exception e) {
                    Logger.getLogger(getClass().getName()).log(Level.ERROR, "Get plugin[name=" + name + "]'s language configuration failed",
                            e);
                }
            }
        }
    }
977857
public Map<String, String> readStringValues(HKey hk, String key) throws RegistryException {
		return readStringValues(hk, key, null);
	}
512804
private function readLangString()
    {
        while (!$this->tokenIs(';')) {
            $this->getNextToken();

            if ($this->tokenIs('[')) {
                $this->subParserSquareBracket();
                continue;
            }
            if ($this->tokenIs('=')) {
                // right hand of the assignment.
                $this->getNextToken();

                if ($this->tokenIs(T_ARRAY) || $this->tokenIs('[')) {
                    $arrayParser = new ArrayParser($this, 1);
                    $arrayParser->parse();
                    $this->debug('After array. ' . var_export($this->getToken(), true));
                } else {
                    $subparser = new StringValue($this);
                    $subparser->parse();

                    $this->file->setValue(implode('.', $this->keystack), $subparser->getValue());
                }

                continue;
            }
            if (!$this->tokenIs(']')) {
                $this->bailUnexpectedToken();
            }
        }

        if ($this->tokenIs(';')) {
            // Reset stack.
            $this->resetStack();
        }
    }
1217209
public Map<String, String> readStringValues(HKey hk, String key, String charsetName) throws RegistryException {
		try {
			return ReflectedMethods.readStringValues(hk.root(), hk.hex(), key, charsetName);
		} catch (Exception e) {
			throw new RegistryException("Cannot read values from key " + key, e);
		}
	}
762922
public Reader createScript(Charset charset) {

		// Determine wether this is run-app or run-war style of runtime.
		boolean warDeployed = ((Boolean) this.servletContext
				.getAttribute(JawrGrailsConstant.GRAILS_WAR_DEPLOYED))
				.booleanValue();

		// Spring message bundle object, the same used by grails.
		GrailsBundleMessageSource messageSource = new GrailsBundleMessageSource(
				warDeployed);
		
		messageSource.setFallbackToSystemLocale(control.isFallbackToSystemLocale());
		messageSource.setFilters(filterList);

		if (warDeployed) {
			messageSource.setResourceLoader(new ServletContextResourceLoader(
					this.servletContext));

		}
		messageSource.setBasenames(getBaseNames(warDeployed));

		Properties props = messageSource.getAllMessages(locale);
		return doCreateScript(props);
	}
589776
private void loadLanguageInfo() {
        // load coarse map
        coarseMap = new HashMap<>();
        try {
            try (BufferedReader br = new BufferedReader(new FileReader(options.unimapFile))) {
                String str;
                while ((str = br.readLine()) != null) {
                    String[] data = str.split("\\s+");
                    coarseMap.put(data[0], data[1]);
                }
            }

            coarseMap.put("<root-POS>", "ROOT");
        } catch (Exception e) {
            logger.warn("Couldn't find coarse POS map for this language");
        }

        // fill conj word
        conjWord = new HashSet<>();
        conjWord.add("and");
        conjWord.add("or");

    }
650522
@Override
	protected void loadProperties(final Properties props) throws IOException {
		if (locations != null) {
			for (int i = 0; i < locations.length; i++) {
				final Resource location = locations[i];
				if (logger.isInfoEnabled()) {
					logger.info("Loading properties file from " + location);
				}
				File file = null;
				InputStream is = null;
				try {
					try {
						file = location.getFile();
						is = new BufferedInputStream(new FileInputStream(file));
					} catch (final IOException ie) {// ignore
					} finally {
						if (file == null) {
							is = location.getInputStream();
						}
					}

					if (location.getFilename().toLowerCase().endsWith(Constants.XML_FILE_EXTENSION)) {
						persister.loadFromXml(props, is);
					} else if (location.getFilename().toLowerCase().endsWith(Constants.JSON_FILE_EXTENSION)) {
						if (fileEncoding != null) {
							persister.loadFromJson(props, new InputStreamReader(is, Charset.forName(fileEncoding)));
						} else {
							persister.loadFromJson(props, is);
						}
					} else if (location.getFilename().toLowerCase().endsWith(Constants.YAML_FILE_EXTENSION)) {
						if (fileEncoding != null) {
							persister.loadFromYAML(props, new InputStreamReader(is, Charset.forName(fileEncoding)));
						} else {
							persister.loadFromYAML(props, is);
						}
					} else {
						if (fileEncoding != null) {
							persister.load(props, new InputStreamReader(is, Charset.forName(fileEncoding)));
						} else {
							persister.load(props, is);
						}
					}
				} catch (final IOException ex) {
					if (ignoreResourceNotFound) {
						if (logger.isWarnEnabled()) {
							logger.warn("Could not load properties from " + location + ": " + ex.getMessage());
						}
					} else {
						throw ex;
					}
				} finally {
					if (is != null) {
						is.close();
					}
				}
			}
		}
	}
738807
static Map<String,String> loadContent( String lang ) {

		Map<String,String> result = new LinkedHashMap<> ();
		try {
			InputStream in = TranslationBundle.class.getResourceAsStream( "/" + lang + ".json" );
			ByteArrayOutputStream os = new ByteArrayOutputStream();
			Utils.copyStreamSafely( in, os );
			String content = os.toString( "UTF-8" );

			Matcher m = Pattern.compile( ROW_PATTERN ).matcher( content );
			while( m.find()) {

				// Get the value
				String s = m.group( 2 );

				// Replace i18n parameters here (when it makes sense)
				try {
					ErrorCode ec = ErrorCode.valueOf( m.group( 1 ));
					for( int i=0; i<ec.getI18nProperties().length; i++ ) {
						s = s.replace( "{" + i + "}", ec.getI18nProperties()[ i ]);
					}

				} catch( IllegalArgumentException e ) {
					// nothing
				}

				result.put( m.group( 1 ), s );
			}

		} catch( Exception e ) {
			final Logger logger = Logger.getLogger( TranslationBundle.class.getName());
			Utils.logException( logger, e );
		}

		return result;
	}
630481
public String getLang(final Locale locale, final String key) {
        return langs.get(locale.toString()).getProperty(key);
    }
239305
@Override
	public void afterPropertiesSet() {

		super.afterPropertiesSet();

		boolean fallbackToSystemLocale = config.getBooleanProperty(
				JawrConstant.JAWR_LOCALE_GENERATOR_FALLBACK_TO_SYSTEM_LOCALE, DEFAULT_FALLBACK_TO_SYSTEM_LOCALE);

		String charsetName = config.getProperty(JawrConstant.JAWR_LOCALE_GENERATOR_RESOURCE_BUNDLE_CHARSET,
				DEFAULT_RESOURCE_BUNDLE_CHARSET);

		Charset charset = Charset.forName(charsetName);

		control = new MessageBundleControl(fallbackToSystemLocale, charset);
	}
1114214
public <T> T getField(String locale, String key) {
    return localize(locale).getField(key);
  }
404047
private void readPropertiesFiles() {

        if (this.configurationFileWildcard.isEmpty() || this.configurationFileExtension.isEmpty()) {
            // Skip configuration loading
            LOGGER.log(SKIP_CONF_LOADING);

        } else {
            // Assemble the regex pattern
            final Pattern filePattern = Pattern.compile(this.configurationFileWildcard + "\\." + this.configurationFileExtension);

            // Retrieve all resources from default classpath
            final Collection<String> list = ClasspathUtility.getClasspathResources(filePattern);

            LOGGER.log(CONFIG_FOUND, list.size(), list.size() > 1 ? "s" : "");

            for (final String confFilename : list) {
                readPropertiesFile(confFilename);
            }
        }
    }
242592
protected void parseProperties(Element element, Map<String, String> properties) {

    for (Element childElement : element.elements()) {
      if(PROPERTY.equals(childElement.getTagName())) {
        String resolved = PropertyHelper.resolveProperty(System.getProperties(), childElement.getText());
        properties.put(childElement.attribute(NAME), resolved);
      }
    }

  }
420589
protected static function createProperties(array $properties, &$lang)
    {
        // Extract the language (if present)
        $properties = self::createLanguage($properties, $lang);

        $mfProperties = [];
        foreach ($properties as $propertyName => $propertyValues) {
            // Process property values
            if (is_array($propertyValues)) {
                $mfProperties[] = (object)[
                    'profile' => self::MF2_PROFILE_URI,
                    'name'    => $propertyName,
                    'values'  => self::createProperty($propertyValues)
                ];
            }
        }

        return $mfProperties;
    }
21300
public Properties getAllMessages(Locale locale) {

		Properties props = new Properties();
		Properties mergedProps = null;
		if (locale == null) {
			locale = Locale.getDefault();
		}
		mergedProps = getMergedProperties(locale).getProperties();

		Set<Entry<Object, Object>> entries = mergedProps.entrySet();
		for (Entry<Object, Object> entry : entries) {
			String key = (String) entry.getKey();
			if (LocaleUtils.matchesFilter(key, filters)) {

				try {
					// Use the property encoding of the file
					String msg = getMessage(key, new Object[0], locale);
					
					// When war is deployed, the resource bundle are encoded in ISO 8859-1
					// and otherwise in UTF-8 
					// Check the following link for more detail https://grails.org/Internationalization
					if(!warDeployed){
						msg = new String(msg.getBytes(CHARSET_ISO_8859_1),
								CHARSET_UTF_8);
					}

					props.put(key, msg);
				} catch (NoSuchMessageException e) {
					// This is expected, so it's OK to have an empty catch
					// block.
					if (LOGGER.isDebugEnabled())
						LOGGER.debug("Message key [" + key + "] not found.");
				} catch (UnsupportedEncodingException e) {
					LOGGER.warn("Unable to convert value of message bundle associated to key '"
							+ key + "' because the charset is unknown");
				}
			}
		}
		return props;
	}
978216
private static Set<String>  parseSystemLanguage(String val)
   {
      TextScanner      scan = new TextScanner(val);
      HashSet<String>  result = new HashSet<>();

      while (!scan.empty())
      {
         String language = scan.nextToken();
         int  hyphenPos = language.indexOf('-'); 
         if (hyphenPos != -1) {
            language = language.substring(0, hyphenPos);
         }
         // Get canonical version of language code in case it has changed (see the JavaDoc for Locale.getLanguage())
         language = new Locale(language, "", "").getLanguage();
         result.add(language);
         scan.skipWhitespace();
      }
      return result;
   }
168121
protected static Charset getCharset(final Map<String, String> properties) {
		String charsetName = properties.get("charset");
		try {
			return charsetName == null ? Charset.defaultCharset() : Charset.forName(charsetName);
		} catch (IllegalArgumentException ex) {
			InternalLogger.log(Level.ERROR, "Invalid charset: " + charsetName);
			return Charset.defaultCharset();
		}
	}