我正在尝试在我的网站上实施谷歌音译。它正在使用所有支持的印度语言。但是当我选择英语时,它会显示一些错误,例如' targetLangCode数组中不支持的语言en '。请帮我解决这个问题。 这是我的代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.js"></script>
<script type="text/javascript" src="jquery-2.2.3.min.js"></script>
<script>
google.load("elements", "1", {
packages: "transliteration"
});
</script>
</head>
<body>
<select id="languageOptions">
<option value="English">English</option>
<option value="Unicode">Unicode</option>
</select>
<select name="langpair" style="height:32px; padding:0; display:none" id="langpair" size="1">
<option value="HINDI" selected>Hindi</option>
<option value="BENGALI">BENGALI</option>
<option value="TELUGU">Telugu</option>
<option value="MARATHI">Marathi</option>
<option value="TAMIL">Tamil</option>
<option value="URDU">Urdu</option>
<option value="KANNADA">Kannada</option>
<option value="GUJARATI">Gujarati</option>
<option value="MALAYALAM">Malayalam</option>
<option value="PUNJABI">PUNJABI</option>
<option value="SANSKRIT">SANSKRIT</option>
<option value="NEPALI">Nepali</option>
<option value="ARABIC">Arabic</option>
<option value="SINDHI">Sindhi</option>
</select>
<br/>
<textarea class="form-control" maxlength="160" id="message" name="message" rows="3" placeholder="Message"></textarea>
<hr>
<br/>
<script>
$('#languageOptions).change(function() {
if($(this).val() == 'Unicode') {
$('#langpair').css('display', 'inline-block');
}
else {
$('#langpair').css('display', 'none');
}
)};
var options = {
shortcutKey: 'ctrl+g',
transliterationEnabled: true,
sourceLanguage: 'en',
destinationLanguage: ['hi'],
};
var control = new google.elements.transliteration.TransliterationControl(options);
control.makeTransliteratable(['message']);
$("#langpair").change(function() {
var data = this.value;
var destinationLanguage = google.elements.transliteration.LanguageCode[data];
control.setLanguagePair('en', destinationLanguage);
});
</script>
</body>
</html>
如何将默认语言设置为“英语”。我试图将sourceLanguage和destinationLanguage更改为其他语言,并且其工作正常。但如果destinationLanguage设置为'en',则显示错误。
答案 0 :(得分:1)
您的代码失败,因为您不能使源语言和目标语言相同。从英语到英语的音译是没有意义的。它不是有效的一对
确切的错误是
不支持的sourceLanguage&amp; targetLanguage对:sourceLanguage:en targetLanguage:en
默认的源语言是英语,您无需设置它。来自官方文件
sourceLanguage是一个必需字符串,它使用LanguageCode枚举指定源语言(如google.elements.transliteration.ENGLISH中所示)。目前,英语是唯一受支持的源语言。
并且您只设置 目标语言 默认设置。因此,您必须在HTML中选择一种默认语言,您可以通过将所选属性添加到选项标签来实现
Create table #Sales (Shop_ID int, Product_Id char(1), [Date] date, [Week] int, [Year] int)
Insert into #Sales Values (1, 'A', '2015-01-26', 5, 2015)
Insert into #Sales Values (1, 'A', '2015-02-02', 6, 2015)
Insert into #Sales Values (1, 'B', '2015-01-03', 1, 2015)
Insert into #Sales Values (2, 'C', '2015-01-15', 3, 2015)
Insert into #Sales Values (2, 'C', '2015-01-26', 5, 2015)
Insert into #Sales Values (2, 'C', '2015-01-02', 6, 2015)
Insert into #Sales Values (2, 'C', '2015-01-03', 7, 2015)
select a.shop_id, a.product_id, a.[date], a.[week], a.[year], sum([WeekSale]) OVER (PARTITION BY [Shop_ID], [Product_ID], [Year] ORDER BY [Shop_ID], [Product_ID], [Year], [Week]) as [NoWeekSales]
from
(
select *
, iif(Lag([Week], 1,null) OVER (PARTITION BY [Shop_ID], [Product_ID], [Year] ORDER BY [Shop_ID], [Product_ID], [Year], [Week])=[Week]-1 ,1,0) as [WeekSale]
from #sales
) a
order by [Shop_ID], [Product_ID], [Year], [Week]