| /** |
| * Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Florian Pirchner - Initial implementation |
| */ |
| package org.eclipse.osbp.runtime.common.i18n; |
| |
| import java.net.URL; |
| import java.util.Locale; |
| |
| import org.eclipse.osbp.runtime.common.dispose.AbstractDisposable; |
| |
| // TODO: Auto-generated Javadoc |
| /** |
| * The I18nService uses the given URLs to add property files. |
| * <p> |
| * See {@link I18nRegistry} for details about the file name pattern. |
| */ |
| public class URLI18nService extends AbstractDisposable implements II18nService { |
| |
| /** The registry. */ |
| private I18nRegistry registry = new I18nRegistry(); |
| |
| /** |
| * Append the translations. |
| * |
| * @param url |
| * the url |
| */ |
| public void append(URL url) { |
| checkDisposed(); |
| registry.addResource(url); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.runtime.common.i18n.II18nService#getValue(java.lang.String, java.util.Locale) |
| */ |
| @Override |
| public String getValue(String i18nKey, Locale locale) { |
| checkDisposed(); |
| return registry.findTranslation(locale, i18nKey); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.osbp.runtime.common.dispose.AbstractDisposable#internalDispose() |
| */ |
| @Override |
| protected void internalDispose() { |
| registry = null; |
| } |
| |
| } |