use of ai.elimu.model.v2.enums.Language in project KaellyBot by Kaysoro.
the class Translator method getLanguageFrom.
/**
* Détermine une langue à partir d'une source textuelle
* @param source Source textuelle
* @return Langue majoritaire détectée au sein de la source
*/
private static Language getLanguageFrom(String source) {
TextObject textObject = CommonTextObjectFactories.forDetectingOnLargeText().forText(source);
LdLocale lang = getLanguageDetector().detect(textObject).or(LdLocale.fromString(Constants.defaultLanguage.getAbrev().toLowerCase()));
for (Language lg : Language.values()) if (lang.getLanguage().equals(lg.getAbrev().toLowerCase()))
return lg;
return Constants.defaultLanguage;
}
use of ai.elimu.model.v2.enums.Language in project KaellyBot by Kaysoro.
the class Translator method getLanguageFrom.
/**
* Fournit la langue utilisée dans un salon textuel
* @param channel Salon textuel
* @return Langue de la guilde ou du salon si précisé
*/
public static Language getLanguageFrom(MessageChannel channel) {
Language result = Constants.defaultLanguage;
if (channel instanceof GuildMessageChannel) {
Guild guild = Guild.getGuild(((GuildMessageChannel) channel).getGuild().block());
result = guild.getLanguage();
ChannelLanguage channelLanguage = ChannelLanguage.getChannelLanguages().get(channel.getId().asLong());
if (channelLanguage != null)
result = channelLanguage.getLang();
}
return result;
}
use of ai.elimu.model.v2.enums.Language in project KaellyBot by Kaysoro.
the class Translator method getLanguageFrom.
public static Language getLanguageFrom(RestChannel channel) {
Guild guild = Guild.getGuilds().get(channel.getData().block().guildId().get().asString());
Language result = guild.getLanguage();
ChannelLanguage channelLanguage = ChannelLanguage.getChannelLanguages().get(channel.getData().block().id().asLong());
if (channelLanguage != null)
result = channelLanguage.getLang();
return result;
}
Aggregations