当前位置: 首页>>代码示例>>Java>>正文


Java Language.fromString方法代码示例

本文整理汇总了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;
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:20,代码来源:MicrosoftTranslateBox.java

示例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;
    }
}
 
开发者ID:esutoniagodesu,项目名称:egd-web,代码行数:12,代码来源:MicrosoftTranslateService.java

示例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));
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:5,代码来源:MicrosoftTranslateBox.java

示例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);

            }

        }
    }
 
开发者ID:pranayairan,项目名称:Dexterapps-Translation-Util,代码行数:33,代码来源:TranslateTextForIOS.java

示例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);
                            
			}

		}
                
	}
 
开发者ID:pranayairan,项目名称:Dexterapps-Translation-Util,代码行数:35,代码来源:TranslateTextForAndroid.java


注:本文中的com.memetix.mst.language.Language.fromString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。