- translates strings used in all kind of Microsoft products
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.7 KiB

# This script translates terminologies used in MS products by sending a SOAP
# request to and extracting the result
# MS Language Portal:
# More info:
# Copyright (C) 2014 Michael Clemens
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program.
# If not, see
# usage: ./MSTerminology "STRING TO BE TRANSLATED"
xml="<soapenv:Envelope xmlns:soapenv=\"\" xmlns:ter=\"\"> \
<soapenv:Header/> \
<soapenv:Body> \
<ter:GetTranslations> \
<ter:text>${text}</ter:text> \
<ter:from>${from}</ter:from> \
<ter:to>${to}</ter:to> \
<ter:searchOperator>Contains</ter:searchOperator> \
<ter:sources> \
<ter:TranslationSource>UiStrings</ter:TranslationSource> \
</ter:sources> \
<ter:unique>false</ter:unique> \
<ter:maxTranslations>1</ter:maxTranslations> \
<ter:includeDefinitions>true</ter:includeDefinitions> \
<ter:products> \
<ter:Product> \
<ter:Name>${product}</ter:Name> \
<ter:Versions> \
<ter:Version> \
<ter:Name>${version}</ter:Name> \
</ter:Version> \
</ter:Versions> \
</ter:Product> \
</ter:products> \
</ter:GetTranslations> \
</soapenv:Body> \
output=$(curl -s -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction: \"\"" -d "${xml}" -X POST
result=$(echo ${output} | sed -e 's,.*<TranslatedText>\([^<]*\)</TranslatedText>.*,\1,g')
if [[ $result != *s:Envelope* ]]; then
echo $result
echo "'"$text"' could not be translated. The server's response was:"
echo $output