|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ephox.editlive.plugins.Translator
public final class Translator
Loads strings using the EditLive! internal translation API.
This API expects language strings to be in files located in the same folder as the resourceClass constructor parameter;
they are loaded using Class.getResourceAsStream(String)
. The filenames must conform to a the following pattern:
String number resolution is performed as follows:
Constructor Summary | |
---|---|
Translator(Class<?> resourceClass)
Constructs the translator. |
Method Summary | |
---|---|
String |
getString(int id)
Resolves a specific string using algorithms detailed in the class header. |
String |
getString(int id,
String... strings)
Calls getString(int) and then replaces tokens inside the resolved string with the given strings. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Translator(Class<?> resourceClass)
resourceClass
- Class used to load language string filesMethod Detail |
---|
public String getString(int id)
id
- string ID to search for
public String getString(int id, String... strings)
getString(int)
and then replaces tokens inside the resolved string with the given strings.
Tokens are in the format {0}, {1}, {2} etc each corresponding to a string in the strings argument.
For example, if string id 1 is "{0} are not {1}" and this API is called using translator.getString(1, "apples", "oranges"); then this method will return "apples are not oranges". Tokens that do not exist in the strings argument are left in their token form within the resolved string.
id
- string ID to search forstrings
- replacement strings for tokens in the resolved string
|
Copyright (c) 2005-2012 Ephox Pty Ltd. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |