Fan sayfamıza katılın
Öyleyse bir link gönderin -
başkalarının da faydalanmasını sağlayın
Translator - MetaTrader 5 için kütüphane
- Görüntülemeler:
- 5427
- Derecelendirme:
- Yayınlandı:
- 2013.01.29 09:47
- Güncellendi:
- 2016.11.22 07:32
- Bu koda dayalı bir robota veya göstergeye mi ihtiyacınız var? Freelance üzerinden sipariş edin Freelance'e git
The class is designed for localization of messages in MQL5 programs. In brief, all that outputs in the log with the help of Print() function and also text messages displayed in Alert(), Comment(), MessageBox() can be done multilingual in one code.
Class methods:
- bool init(string progName, ENUM_LANGUAGES lang) - initialize the object. In the entry we set the name of the program and the code of the language from tabulation in the LanguagesEnum.mqh file.
- string tr(string str) - translates the str* string.
- void print(string str) - types the translation of the str* string in the log.
- void alert(string str) - displays the alert with the translated string*.
- void comment(string str) - displays the comment with the translated string*.
- int messageBox(string text, string caption=NULL, int flags=0) - displays the translated text* in the message window and translates the title of the window*. Returns one of the MessageBox() return codes. As well as the MessageBox(), this method can not be fetched from user indicators.
- * - If the language file does not have the equivalent translation then it returns/displays entering string.
Usage:
- Download Translator.mqh and LanguagesEnum.mqh files to the MetaTrader 5\MQL5\Include folder. The class itself is located in the first file, the list of languages is located in the second file in accordance with ISO 639 standard (at this stage only the languages to which the terminal is translated are listed in the file. If necessary you can add the code of any other language, preferably in accordance with ISO 639 standard to avoid confusion);
- Create a text file translation for "its" language in the format of Alias = Translation, where Alias is an aliased name of the translatable string and also a string-argument by which class methods are subsequently called, Translation is the translation of the text which will be eventually displayed;
- Language file(s) coding: UTF8(without BOM);
- The file name must strictly correspond to the following format: <MQL5 code name>.<Language code in latin capital letter>.ini. For example, the text file with the translation into Russian for MyCode code must be called MyCode.RU.ini. Eventually, the number of language files must correspond to the number of languages into which you want to translate messages;
- Place created language files to MetaTrader 5\MQL5\Files\Languages folder.
In the code:
- Connect the translator file (# include <Traslator.mqh>) in the code (The Expert Advisor, indicator, script);
- Create an object. For example, CTranslator ru;
- Add an input parameter for the translation. For example, input ENUM_LANGUAGES InpToLanguage = RU;
- Initialize the object. For example, ru.init(MQL5InfoString(MQL5_PROGRAM_NAME), InpToLanguage);
- Use any of these methods if necessary. For example, ru.print("Your text").
For an illustrative example the Sample.mq5 script and two language files are attached to it to translate into Russian and Japanese. The result of the work of the script (at first it ran in the chart with the parameter to translate into Russian, then into Japanese):
Recommendations:
Although aliases can be written in any language and also alias may just be an abbreviation instead of a whole phrase. It is better to write in English and without abbreviation. Thus:- even if there is no language file, all messages will be displayed in English,
- the need to write a special file for translation into English is eliminated automatically (those who wrote under Joomla CMS extensions probably understand it easier, as the logic is the same).
MetaQuotes Ltd tarafından Rusçadan çevrilmiştir.
Orijinal kod: https://www.mql5.com/ru/code/1484
The advanced presentation of the Bollinger Bands indicator
Exp_ColorCoppockThe trade system using the ColorCoppock oscillator.