本文整理汇总了Java中com.memetix.mst.language.Language.fromString方法的典型用法代码示例。如果您正苦于以下问题:Java Language.fromString方法的具体用法?Java Language.fromString怎么用?Java Language.fromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.memetix.mst.language.Language
的用法示例。
在下文中一共展示了Language.fromString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translate
import com.memetix.mst.language.Language; //导入方法依赖的package包/类
public static String translate(String text, Topic sourceLangTopic, Topic targetLangTopic, boolean markTranslation) {
try {
String sourceLangStr = LanguageBox.getCodeForLangTopic(sourceLangTopic);
String targetLangStr = LanguageBox.getCodeForLangTopic(targetLangTopic);
if(sourceLangStr != null && targetLangStr != null) {
Language sourceLang = Language.fromString(sourceLangStr);
Language targetLang = Language.fromString(targetLangStr);
if(sourceLang != null && targetLang != null) {
return translate(text, sourceLang, targetLang, markTranslation);
}
}
}
catch(Exception e) {
e.printStackTrace();
}
return null;
}
示例2: translate
import com.memetix.mst.language.Language; //导入方法依赖的package包/类
public static String translate(String from, String to, String string) {
try {
Language lfrom = Language.fromString(from);
Language lto = Language.fromString(to);
log.debug("translate: {}, {}, {}", string, lfrom, lto);
return Translate.execute(string, lfrom, lto);
} catch (Exception e) {
log.error("translate: ", e.getMessage(), e);
return null;
}
}
示例3: getLanguageForCode
import com.memetix.mst.language.Language; //导入方法依赖的package包/类
public static Language getLanguageForCode(String code) {
if(code == null) return null;
return Language.fromString(LanguageBox.getNameFor6391Code(code));
}
示例4: translateIOSText
import com.memetix.mst.language.Language; //导入方法依赖的package包/类
public void translateIOSText(String clientID, String clientSecret, String sourceFilePath, String outputFolder, String baseLanguage) {
baseStringResourcesMapping = new HashMap<String, Integer>();
iOSStringDOM = new ArrayList<IOSStringMapping>();
baseLanguageStringForTranslation = new ArrayList<String>();
// Parse The XML
parseStringAndGenerateDom(sourceFilePath);
//Now we got the Strings from Localizable.strings lets call the translation method and get the data back
//Let's Get the list of all languages
List<String> supportedLanguage = Arrays.asList(SupportedLanguage.supportedLanguageCode);
ExecutorService executor = Executors.newFixedThreadPool(5);
System.out.println("Translating Resources");
for (String languageCodeForTranslation : supportedLanguage) {
Language from = Language.fromString(baseLanguage);
if (!languageCodeForTranslation.equalsIgnoreCase(baseLanguage)) {
String[] sourceText = baseLanguageStringForTranslation.toArray(new String[baseLanguageStringForTranslation.size()]);
Runnable worker = new TranslateAndSaveiOS(clientID, clientSecret, baseStringResourcesMapping, iOSStringDOM, sourceText, from, languageCodeForTranslation, outputFolder);
executor.execute(worker);
}
}
}
示例5: translateText
import com.memetix.mst.language.Language; //导入方法依赖的package包/类
public void translateText(String clientID,String clientSecret,String sourceFilePath,String outputFolder,String baseLanguage) {
baseStringResourcesMapping = new HashMap<String, Integer>();
stringXmlDOM = new ArrayList<AndroidStringMapping>();
baseLanguageStringForTranslation = new ArrayList<String>();
// Parse The XML
parseXMLAndGenerateDom(sourceFilePath);
//Now we got the Strings from String.xml lets call the translation method and get the data back
//Let's Get the list of all languages
List<String> supportedLanguage = Arrays.asList(SupportedLanguage.supportedLanguageCode);
ExecutorService executor = Executors.newFixedThreadPool(5);
System.out.println("Translating Resources");
for (String languageCodeForTranslation : supportedLanguage) {
Language from = Language.fromString(baseLanguage);
if(!languageCodeForTranslation.equalsIgnoreCase(baseLanguage))
{
String[] sourceText = baseLanguageStringForTranslation.toArray(new String[baseLanguageStringForTranslation.size()]);
Runnable worker = new TranslateAndSaveAndroid(clientID, clientSecret, baseStringResourcesMapping, stringXmlDOM, sourceText, from, languageCodeForTranslation, outputFolder);
executor.execute(worker);
}
}
}