We have added support for strings that require harmonization with numerals to the platform. Now you can generate strings of the “run time 1 second” and “run time 32 seconds” type automatically, without analyzing the numeral in order to use the correct unit of measurement form.
To this end, we added a new StringWithNumber() method to the platform. Its working principle is based on the fact that any numeral in any language can be classified into one of the six categories:
The StringWithNumber() method works as follows. You need to pass there string fragments for those categories that are present in the selected language. You must also pass the numeral itself. As a result, the method, depending on the numeral and language, selects one of the string fragments by placing the numeral in there and then returns it to you.
For example, in the English language, you need to automatically display the following: “So many days left until New Year's Day”. Then, using this method might look like this:
For Counter = 1 To 7 Do String = StringWithNumber("; %1 day; ; ; ; %1 days", 8 - Counter, NumberValueType.Cardinal); Message = New UserMessage; Message.Text = String + " left until New Year's Day"; Message.Message(); EndDo;
Or another example. In English, you must display the following: “January this date, the day of the year”. Then the code will look like this:
For Counter = 1 To 7 Do String = StringWithNumber( "; %1st; %1nd; %1rd; ; %1th", Counter, NumberValueType.Ordinal); Message = New UserMessage; Message.Text = "January " + Counter + ", the " + String + " day of the year"; Message.Message(); EndDo;
Note that these examples illustrate different types of numerals. The first example uses cardinal numerals, while the second - ordinal ones. Cardinal numbers answer the question "How many?" Ordinal numbers answer the question "Which one?"
The spelling of cardinal and ordinal numerals varies, therefore, you need to use different calls of the StringWithNumber() method. For example, in the Russian language, a noun that refers to cardinal numerals is declined according to cases and numbers (1 день, 2 дня, 5 дней), and ordinal numerals are used in the singular form (1-й день, 2-й день, 3-й день, 4-й день). In English, a noun that refers to cardinal numerals is declined only according to numbers (1 day, 2 days), and there are four different forms for ordinal numerals: 1st day, 2nd day, 3rd day, 4th day.
To help you use the new method, we specified in the Syntax Assistant the strings that you must use for each language and for each numeral type (cardinal or ordinal).
Thus, all you have to do is substitute correct measurement unit forms and use the characters "%1" to indicate, in which place of each fragment the numeral will be located.
We have already used the new string generation features in the platform interface. For example, the schedule of a scheduled job now includes the correct numeral form:
The string representation of the planner schedule now contains no spelling errors.
In conclusion, we would like to point out that the new StringWithNumber() method was implemented for 21 languages: