diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..114a057
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,3 @@
+**/.DS_Store
+iris-main.log
+.git
\ No newline at end of file
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..43e39d5
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,11 @@
+*.cls linguist-language=ObjectScript
+*.mac linguist-language=ObjectScript
+*.int linguist-language=ObjectScript
+*.inc linguist-language=ObjectScript
+*.csp linguist-language=Html
+
+*.sh text eol=lf
+*.cls text eol=lf
+*.mac text eol=lf
+*.int text eol=lf
+Dockerfil* text eol=lf
diff --git a/.github/workflows/objectscript-quality.yml b/.github/workflows/objectscript-quality.yml
new file mode 100644
index 0000000..df27ddf
--- /dev/null
+++ b/.github/workflows/objectscript-quality.yml
@@ -0,0 +1,12 @@
+name: objectscriptquality
+on: push
+
+jobs:
+ linux:
+ name: Linux build
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Execute ObjectScript Quality Analysis
+ run: wget https://raw.githubusercontent.com/litesolutions/objectscriptquality-jenkins-integration/master/iris-community-hook.sh && sh ./iris-community-hook.sh
+
diff --git a/.github/workflows_build-push-gcr.yaml b/.github/workflows_build-push-gcr.yaml
new file mode 100644
index 0000000..4272bce
--- /dev/null
+++ b/.github/workflows_build-push-gcr.yaml
@@ -0,0 +1,19 @@
+name: Cloud Run Deploy
+
+on:
+ push:
+ branches:
+ - master
+ - main
+ workflow_dispatch:
+
+jobs:
+ deploy:
+ uses: intersystems-community/demo-deployment/.github/workflows/deployment.yml@master
+ with:
+ # Replace the name: parameter below to have your application deployed at
+ # https://project-name.demo.community.intersystems.com/
+ name: project-name
+ secrets:
+ # Do not forget to add Secret in GitHub Repoository Settings with name SERVICE_ACCOUNT_KEY
+ SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }}
diff --git a/.github/workflows_bump-module-version.yml b/.github/workflows_bump-module-version.yml
new file mode 100644
index 0000000..7c54977
--- /dev/null
+++ b/.github/workflows_bump-module-version.yml
@@ -0,0 +1,28 @@
+name: versionbump
+
+on:
+ push:
+ branches:
+ - master
+ - main
+ release:
+ types:
+ - released
+permissions:
+ contents: write
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Bump version
+ run: |
+ git config --global user.name 'ProjectBot'
+ git config --global user.email 'bot@users.noreply.github.com'
+ VERSION=$(sed -n '0,/.* the aim of this function is to convert numbers into text. It allows a maximum number of 15 digits. The translation is done in several languages. The allowed languages areNumberTranslate
-/// Overview
-///
-///
The function also allows to treat the numbers of 10^9 (millards) in English-speaking countries format. See the following link Billion Wikipedia
-///-/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(123,.tSc) -/// one hundred and twenty-three -/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(123,.tSc,"es") -/// ciento veintitres -/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(123,.tSc,"ca") -/// cent vint-i-tres -/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(1000000000,.tSc,"en",1) -/// one billion -/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(1000000000,.tSc,"en",0) -/// one thousand millions -/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(1000000000000,.tSc,"en",1) -/// one trillion -/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(1000000000000,.tSc,"en",0) -/// one billion -///-///
In case of error, you can catch the error with the status variable -///
-/// USER> set text=##class(NumberTranslate.NumberTranslate).GetText(123,.tSc,"fr") -/// USER> if ('tSc) { w $System.Status.GetErrorText(tSc) } else { w text } -/// ERROR #420: Lang fr not exists -///-/// -Class NumberTranslate.NumberTranslate Extends %RegisteredObject [ Not ProcedureBlock ] -{ - -/// Internal method to get trio of digit and translate according to language -Method Trio(pTrio As %String) As %String -{ - if (^NumberTranslate("Current","debug")) - { - w "--------------",! - w "Value trio:",?25,pTrio,! - } - set lcent = $EXTRACT(pTrio,1,1) - set lten = $EXTRACT(pTrio,2,2) - set lunit = $EXTRACT(pTrio,3,3) - - set lang = ^NumberTranslate("Current","lang") - - set figure = "" - - // First figure (cent) - if (lcent>0) - { - set figure=figure_$SELECT((lcent=1)&&((lten=0)&&(lunit=0)):^NumberTranslate("Config","lang",lang,"hundred",0), - 1:^NumberTranslate("Config","lang",lang,"hundred",lcent)) - } - - if (lcent>0)&&((lten>0)||(lunit>0)) - { - set figure=figure_^NumberTranslate("Config","lang",lang,"concat-cents") - } - - // Second figure (tens) - if ((lten>=3)&&(lten<=9)) - { - set figure = figure_$SELECT(lunit=0:%obj.GetDigit(lten*10)_" ",lunit>0:%obj.GetDigit(lten*10)_^NumberTranslate("Config","lang",lang,"concat-tens")) - } elseif (lten = 2) - { - set figure = figure_$SELECT(lunit=0:^NumberTranslate("Config","lang",lang,"unit",29)_" ",1:%obj.GetDigit(lten*10)) - // Condition only for Spanish and twenty - if (lang'="es")&&(lunit>0) - { - set figure = figure_^NumberTranslate("Config","lang",lang,"concat-tens") - } - } elseif (lten = 1) - { - set figure = figure_" "_%obj.GetDigit((lten*10)+lunit)_" " - } - - // Third figure (unit) - if ((lunit>0)&&(lten'=1)) - { - set figure = figure_%obj.GetDigit(lunit) - } - - - // Remove all double spaces - set figure=$Replace(figure," "," ") - quit figure -} - -/// Internal method to get the text of digit -Method GetDigit(pNumber As %Integer) As %String -{ - set sCurrent = "" - set lang = ^NumberTranslate("Current","lang") - - if (pNumber <= 20) - { - // From 1 to 20 is the same than position of Unit - set sCurrent = ^NumberTranslate("Config","lang",lang,"unit",pNumber) - } - else - { - set lNumber = pNumber - 30 - set lPos = 0 - if (lNumber < 0) - { - set lNumber = lNumber * -1 - set lPos = (lNumber/10) + 21 - } - else - { - if (lNumber = 0) - { - set lPos = 21 - } - else - { - set lPos = (lNumber/10) + 21 - } - } - set sCurrent = ^NumberTranslate("Config","lang",lang,"unit",lPos) - } - - quit sCurrent -} - -/// Translate a number to text -ClassMethod GetText(pNumber As %Decimal, Output pStatus As %Status, pLang As %String = "en", pEngBillion As %Boolean = 0) As %String -{ - quit:pLang="ru" $piece(..RussianMethod(pNumber), " руб") - set %obj=..%New() - set pStatus = $$$OK - set tResult = "" - // Check if code is installed - if ($Get(^NumberTranslate("Config"))'=1) - { - do ##class(NumberTranslate.Initialize).Initialize() - } - - //Allowed langs ^NumberTranslate("Config","lang") - if ('$listfind($LISTFROMSTRING(^NumberTranslate("Config","lang"),";"),pLang)) - { - SET pStatus = $System.Status.Error(420,"Lang",pLang) - Quit tResult - } - - set ^NumberTranslate("Current","lang")=pLang - set ^NumberTranslate("Current","culture")=$CASE(pEngBillion,1:"en",0:"") - - set number = $System.SQL.TOCHAR(pNumber,"000000000000000") - set billion=$Extract(number,0,4) - set millard=$Extract(number,5,7) - set million=$Extract(number,8,10) - set thousand=$Extract(number,11,13) - set cents=$Extract(number,14,16) - - if (^NumberTranslate("Current","debug")) - { - w "Number to process:",?25,number,! - w "(EUR) Billion:",?25,billion,! - w "Millard:",?25,millard,! - w "Million:",?25,million,! - w "Thousand:",?25,thousand,! - w "Cents:",?25,cents,! - } - - // Five blocks, watch out with billion USA and billion EUR - for block=1:1:5 - { - if (block=1) // (EUR) Billion / (ENG) Trillion - { - // Acording to culture, the text could be trillion or billion - set textBlock=$CASE(pEngBillion,1:^NumberTranslate("Config","lang",pLang,"trillion"),0:^NumberTranslate("Config","lang",pLang,"billion")) - set textBlocks=$CASE(pEngBillion,1:^NumberTranslate("Config","lang",pLang,"trillions"),0:^NumberTranslate("Config","lang",pLang,"billions")) - - set tResult=tResult_" "_$SELECT($Number(billion)=1:^NumberTranslate("Config","lang",pLang,"unit")_" "_textBlock,$Number(billion)>1:%obj.Trio(billion)_" "_textBlocks,1:"") - } - if (block=2) // (EUR) Thousand million / (ENG) Billion - { - // Acording to culture, the text could be billion or thousand (of billion) - set textBlock=$CASE(pEngBillion,1:^NumberTranslate("Config","lang",pLang,"billion"),0:^NumberTranslate("Config","lang",pLang,"thousand")) - set textBlocks=$CASE(pEngBillion,1:^NumberTranslate("Config","lang",pLang,"billions"),0:^NumberTranslate("Config","lang",pLang,"thousand")) - - set tResult=tResult_" "_$SELECT($Number(millard)=1:^NumberTranslate("Config","lang",pLang,"unit")_" "_textBlock, $Number(millard)>1:%obj.Trio(millard)_" "_textBlocks, 1:"") - - } - if (block=3) // Million - { - set textBlock=^NumberTranslate("Config","lang",pLang,"million") - set textBlocks=^NumberTranslate("Config","lang",pLang,"millions") - - set tResult=tResult_" "_$SELECT($Number(million)=1:^NumberTranslate("Config","lang",pLang,"unit")_" "_textBlock, - $Number(million)>1:%obj.Trio(million)_" "_textBlocks, - $Number(millard)>0: $SELECT(pEngBillion=1:" ",1:" "_textBlocks),1:"") - } - if (block=4) // Thousand - { - set textBlock=^NumberTranslate("Config","lang",pLang,"thousand") - // RU: 1000 - тысяча - // 2000 - 4000: тысячи - // 5000 - 9000: тысяч - if (pLang="ru") - { - set textBlock=textBlock_$SELECT($EXTRACT(thousand,3,3)=1:"а",($EXTRACT(thousand,3,3)>1) && ($EXTRACT(thousand,3,3)<5):"и",1:"") - } - - // In RU, ES and CA, just for one thousand, the number is omitted. The rest of language is showed - if (pLang="en") - { - set tResult=tResult_" "_$SELECT($Number(thousand)>0:%obj.Trio(thousand)_" "_textBlock,1:"") - } else - { - set tResult=tResult_" "_$SELECT($Number(thousand)=1:textBlock, $Number(thousand)>1:%obj.Trio(thousand)_" "_textBlock,1:"") - } - } - if (block=5) // Cents - { - set tResult=tResult_" "_%obj.Trio(cents) - } - } - - kill %obj - set tResult = $ZSTRIP($Replace(tResult," "," "),"<>"," ") - Quit tResult -} - -/// Russian Translate -ClassMethod RussianMethod(summa As %Decimal = "") As %String -{ - new SUMMA,SUMMAP,%X,%X0,%X1,R0,R1,VV,V2,V3,V - set SUMMA=summa - I +SUMMA'<1000000000000 S SUMMAP=SUMMA G END0 ;### - I +SUMMA<0 S SUMMA=-SUMMA - S %X=+$P(SUMMA,".",1),SUMMAP="",VV=0 - ;I %X=0 S SUMMAP="ноль рублей" - I %X=0 S SUMMAP="ноль " - I %X>0 D PRUBL - S V2=$E(%X,$L(%X)-1),V3=$E(%X,$L(%X)) - I V3=1,V2'=1 S SUMMAP=SUMMAP_" рубль",VV=1 - I ((V3=2)!(V3=3)!(V3=4))&(V2'=1) S SUMMAP=SUMMAP_" рубля",VV=1 - I ((V3=1)!(V3=2)!(V3=3)!(V3=4))&(V2=1) S SUMMAP=SUMMAP_" рублей",VV=1 - I V3>4 S SUMMAP=SUMMAP_" рублей",VV=1 - I VV=0 S SUMMAP=SUMMAP_" рублей" - S %X=$P(SUMMA,".",2) I %X="" S %X="00" - I %X?1N S %X=%X_"0",(V1,V)="0" - I %X?2N S V1=$E(%X,1,1),V=$E(%X,2,2) -R1 I (V="1")&(V1'="1") S SUMMAP=SUMMAP_" "_%X_" копейка" - I ((V="2")!(V="3")!(V="4"))&(V1'="1") S SUMMAP=SUMMAP_" "_%X_" копейки" - I ((V'="1")&(V'="2")&(V'="3")&(V'="4"))!(V1="1") S SUMMAP=SUMMAP_" "_%X_" копеек" - I $E(SUMMAP)=" " S SUMMAP=$E(SUMMAP,2,255) - S SUMMAP=$TR($E(SUMMAP),"одтчпшсвн","ОДТЧПШСВН")_$E(SUMMAP,2,255) -END0 K %X,%X0,%X1,R0,R1 - Q (SUMMAP) ;1 - ;- -PRUBL ; Euro - D PMILR,PMILE,PtYS,PEDIN - Q ;Added - ;- -PMILR ;BILLION - S %X0=%X\1000000000 Q:%X0=0 ;### - D PSoT,PDES - -RRR3 S SUMMAP=SUMMAP_" миллиард"_$S(%X0#100=0:"ов",%X0#100>10&(%X0#100<21):"ов",%X0#10>1&(%X0#10<5):"а",%X0#10=1:"",1:"ов")_" " - K R3 - Q ;PMILR - ;- -PMILE ;Millions - ;S %X0=%X\1000000 Q:%X0=0 ;### - S %X0=%X#1000000000\1000000 Q:%X0=0 ;### - D PSoT,PDES - -R3 S SUMMAP=SUMMAP_" миллион"_$S(%X0#100=0:"ов",%X0#100>10&(%X0#100<21):"ов",%X0#10>1&(%X0#10<5):"а",%X0#10=1:"",1:"ов")_" " - K R3 - Q ;PMILE - ;- -PtYS ;THOUSAND - S %X0=%X#1000000\1000 Q:%X0=0 ;### - D PSoT,PDES - S %X1=$E(SUMMAP,$L(SUMMAP)-2,$L(SUMMAP)) - I %X1="ва " S SUMMAP=$E(SUMMAP,1,$L(SUMMAP)-3)_"ве " - I %X1="ин " S SUMMAP=$E(SUMMAP,1,$L(SUMMAP)-3)_"на " -QQ S SUMMAP=SUMMAP_"тысяч"_$S(%X0#100=11:"",%X0#100=12:"",%X0#100=13:"",%X0#100=14:"",%X0#10=1:"а",%X0#10>1&(%X0#10<5):"и",1:"")_" " - K R4,R5,R6 - Q ;PtYS - ;- -PEDIN ;UNITS IN BREAKDOWN - S %X0=%X#1000 Q:%X0=0 ;### - D PSoT,PDES - Q ;PtDIN - ;- -PSoT ;HUNDREDS - S %X1=%X0\100 Q:%X1=0 ;### -R7 S S1="сто" -R8 S S2="двести" -R9 S S3="триста" -R10 S S4="четыреста" -R11 S S5="пятьсот" -R12 S S6="шестьсот" -R13 S S7="семьсот" -R14 S S8="восемьсот" -R15 S S9="девятьсот" - S SUMMAP=SUMMAP_$S(%X1=1:S1,%X1=2:S2,%X1=3:S3,%X1=4:S4,%X1=5:S5,%X1=6:S6,%X1=7:S7,%X1=8:S8,%X1=9:S9)_" " - K S1,S2,S3,S4,S5,S6,S7,S8,S9 - Q ;PSoT - ;- -PDES ;TENS - S %X1=%X0#100\10 Q:%X=0 ;### - I %X1=1 D PDC Q ;### -R17 S D2="двадцать" -R18 S D3="тридцать" -R19 S D4="сорок" -R20 S D5="пятьдесят" -R21 S D6="шестьдесят" -R22 S D7="семьдесят" -R23 S D8="восемьдесят" -R24 S D9="девяносто" - S SUMMAP=SUMMAP_$S(%X1=2:D2,%X1=3:D3,%X1=4:D4,%X1=5:D5,%X1=6:D6,%X1=7:D7,%X1=8:D8,%X1=9:D9,1:"")_" " - K D2,D3,D4,D5,D6,D7,D8,D9 - D PoDIN - Q ;PDES - ;- -PDC ; - S %X1=%X0#10 -R25 S F0="десять" -R26 S F1="одиннадцать" -R27 S F2="двенадцать" -R28 S F3="тринадцать" -R29 S F4="четырнадцать" -R30 S F5="пятнадцать" -R31 S F6="шестнадцать" -R32 S F7="семнадцать" -R33 S F8="восемнадцать" -R34 S F9="девятнадцать" - S SUMMAP=SUMMAP_$S(%X1=0:F0,%X1=1:F1,%X1=2:F2,%X1=3:F3,%X1=4:F4,%X1=5:F5,%X1=6:F6,%X1=7:F7,%X1=8:F8,%X1=9:F9) - K F0,F1,F2,F3,F4,F5,F6,F7,F8,F9 - Q ;PDC - ;- -PoDIN ;UNITS - S %X1=%X0#10 I %X1=0 Q ;### - S SUMMAP=SUMMAP_$S(%X1=1:"один",%X1=2:"два",%X1=3:"три",%X1=4:"четыре",%X1=5:"пять",%X1=6:"шесть",%X1=7:"семь",%X1=8:"восемь",%X1=9:"девять",1:"")_" " - K E1,E2,E3,E4,E5,E6,E7,E8,E9 - Q ;PoDIN -} - -} +/// +///
the aim of this function is to convert numbers into text.
+///It allows a maximum number of 15 digits.
+///The translation is done in several languages. The allowed languages are
+///The function also allows to treat the numbers of 10^9 (millards) in English-speaking countries format. See the following link Billion Wikipedia
+///+/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(123,.tSc) +/// one hundred and twenty-three +/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(123,.tSc,"es") +/// ciento veintitres +/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(123,.tSc,"ca") +/// cent vint-i-tres +/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(1000000000,.tSc,"en",1) +/// one billion +/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(1000000000,.tSc,"en",0) +/// one thousand millions +/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(1000000000000,.tSc,"en",1) +/// one trillion +/// USER> w ##class(NumberTranslate.NumberTranslate).GetText(1000000000000,.tSc,"en",0) +/// one billion +///+///
In case of error, you can catch the error with the status variable +///
+/// USER> set text=##class(NumberTranslate.NumberTranslate).GetText(123,.tSc,"fr") +/// USER> if ('tSc) { w $System.Status.GetErrorText(tSc) } else { w text } +/// ERROR #420: Lang fr not exists +///+/// +Class NumberTranslate.NumberTranslate Extends %RegisteredObject [ Not ProcedureBlock ] +{ + +/// Internal method to get trio of digit and translate according to language +Method Trio(pTrio As %String) As %String +{ + if (^NumberTranslate("Current","debug")) + { + w "--------------",! + w "Value trio:",?25,pTrio,! + } + set lcent = $EXTRACT(pTrio,1,1) + set lten = $EXTRACT(pTrio,2,2) + set lunit = $EXTRACT(pTrio,3,3) + + set lang = ^NumberTranslate("Current","lang") + + set figure = "" + + // First figure (cent) + if (lcent>0) + { + set figure=figure_$SELECT((lcent=1)&&((lten=0)&&(lunit=0)):^NumberTranslate("Config","lang",lang,"hundred",0), + 1:^NumberTranslate("Config","lang",lang,"hundred",lcent)) + } + + if (lcent>0)&&((lten>0)||(lunit>0)) + { + set figure=figure_^NumberTranslate("Config","lang",lang,"concat-cents") + } + + // Second figure (tens) + if ((lten>=3)&&(lten<=9)) + { + set figure = figure_$SELECT(lunit=0:%obj.GetDigit(lten*10)_" ",lunit>0:%obj.GetDigit(lten*10)_^NumberTranslate("Config","lang",lang,"concat-tens")) + } elseif (lten = 2) + { + set figure = figure_$SELECT(lunit=0:^NumberTranslate("Config","lang",lang,"unit",29)_" ",1:%obj.GetDigit(lten*10)) + // Condition only for Spanish and twenty + if (lang'="es")&&(lunit>0) + { + set figure = figure_^NumberTranslate("Config","lang",lang,"concat-tens") + } + } elseif (lten = 1) + { + set figure = figure_" "_%obj.GetDigit((lten*10)+lunit)_" " + } + + // Third figure (unit) + if ((lunit>0)&&(lten'=1)) + { + set figure = figure_%obj.GetDigit(lunit) + } + + + // Remove all double spaces + set figure=$Replace(figure," "," ") + quit figure +} + +/// Internal method to get the text of digit +Method GetDigit(pNumber As %Integer) As %String +{ + set sCurrent = "" + set lang = ^NumberTranslate("Current","lang") + + if (pNumber <= 20) + { + // From 1 to 20 is the same than position of Unit + set sCurrent = ^NumberTranslate("Config","lang",lang,"unit",pNumber) + } + else + { + set lNumber = pNumber - 30 + set lPos = 0 + if (lNumber < 0) + { + set lNumber = lNumber * -1 + set lPos = (lNumber/10) + 21 + } + else + { + if (lNumber = 0) + { + set lPos = 21 + } + else + { + set lPos = (lNumber/10) + 21 + } + } + set sCurrent = ^NumberTranslate("Config","lang",lang,"unit",lPos) + } + + quit sCurrent +} + +/// Translate a number to text +ClassMethod GetText(pNumber As %Decimal, Output pStatus As %Status, pLang As %String = "en", pEngBillion As %Boolean = 0) As %String +{ + quit:pLang="ru" $piece(..RussianMethod(pNumber), " руб") + set %obj=..%New() + set pStatus = $$$OK + set tResult = "" + // Check if code is installed + if ($Get(^NumberTranslate("Config"))'=1) + { + do ##class(NumberTranslate.Initialize).Initialize() + } + + //Allowed langs ^NumberTranslate("Config","lang") + if ('$listfind($LISTFROMSTRING(^NumberTranslate("Config","lang"),";"),pLang)) + { + SET pStatus = $System.Status.Error(420,"Lang",pLang) + Quit tResult + } + + set ^NumberTranslate("Current","lang")=pLang + set ^NumberTranslate("Current","culture")=$CASE(pEngBillion,1:"en",0:"") + + set number = $System.SQL.TOCHAR(pNumber,"000000000000000") + set billion=$Extract(number,0,4) + set millard=$Extract(number,5,7) + set million=$Extract(number,8,10) + set thousand=$Extract(number,11,13) + set cents=$Extract(number,14,16) + + if (^NumberTranslate("Current","debug")) + { + w "Number to process:",?25,number,! + w "(EUR) Billion:",?25,billion,! + w "Millard:",?25,millard,! + w "Million:",?25,million,! + w "Thousand:",?25,thousand,! + w "Cents:",?25,cents,! + } + + // Five blocks, watch out with billion USA and billion EUR + for block=1:1:5 + { + if (block=1) // (EUR) Billion / (ENG) Trillion + { + // Acording to culture, the text could be trillion or billion + set textBlock=$CASE(pEngBillion,1:^NumberTranslate("Config","lang",pLang,"trillion"),0:^NumberTranslate("Config","lang",pLang,"billion")) + set textBlocks=$CASE(pEngBillion,1:^NumberTranslate("Config","lang",pLang,"trillions"),0:^NumberTranslate("Config","lang",pLang,"billions")) + + set tResult=tResult_" "_$SELECT($Number(billion)=1:^NumberTranslate("Config","lang",pLang,"unit")_" "_textBlock,$Number(billion)>1:%obj.Trio(billion)_" "_textBlocks,1:"") + } + if (block=2) // (EUR) Thousand million / (ENG) Billion + { + // Acording to culture, the text could be billion or thousand (of billion) + set textBlock=$CASE(pEngBillion,1:^NumberTranslate("Config","lang",pLang,"billion"),0:^NumberTranslate("Config","lang",pLang,"thousand")) + set textBlocks=$CASE(pEngBillion,1:^NumberTranslate("Config","lang",pLang,"billions"),0:^NumberTranslate("Config","lang",pLang,"thousand")) + + set tResult=tResult_" "_$SELECT($Number(millard)=1:^NumberTranslate("Config","lang",pLang,"unit")_" "_textBlock, $Number(millard)>1:%obj.Trio(millard)_" "_textBlocks, 1:"") + + } + if (block=3) // Million + { + set textBlock=^NumberTranslate("Config","lang",pLang,"million") + set textBlocks=^NumberTranslate("Config","lang",pLang,"millions") + + set tResult=tResult_" "_$SELECT($Number(million)=1:^NumberTranslate("Config","lang",pLang,"unit")_" "_textBlock, + $Number(million)>1:%obj.Trio(million)_" "_textBlocks, + $Number(millard)>0: $SELECT(pEngBillion=1:" ",1:" "_textBlocks),1:"") + } + if (block=4) // Thousand + { + set textBlock=^NumberTranslate("Config","lang",pLang,"thousand") + // RU: 1000 - тысяча + // 2000 - 4000: тысячи + // 5000 - 9000: тысяч + if (pLang="ru") + { + set textBlock=textBlock_$SELECT($EXTRACT(thousand,3,3)=1:"а",($EXTRACT(thousand,3,3)>1) && ($EXTRACT(thousand,3,3)<5):"и",1:"") + } + + // In RU, ES and CA, just for one thousand, the number is omitted. The rest of language is showed + if (pLang="en") + { + set tResult=tResult_" "_$SELECT($Number(thousand)>0:%obj.Trio(thousand)_" "_textBlock,1:"") + } else + { + set tResult=tResult_" "_$SELECT($Number(thousand)=1:textBlock, $Number(thousand)>1:%obj.Trio(thousand)_" "_textBlock,1:"") + } + } + if (block=5) // Cents + { + set tResult=tResult_" "_%obj.Trio(cents) + } + } + + kill %obj + set tResult = $ZSTRIP($Replace(tResult," "," "),"<>"," ") + Quit tResult +} + +/// Russian Translate +ClassMethod RussianMethod(summa As %Decimal = "") As %String +{ + new SUMMA,SUMMAP,%X,%X0,%X1,R0,R1,VV,V2,V3,V + set SUMMA=summa + I +SUMMA'<1000000000000 S SUMMAP=SUMMA G END0 ;### + I +SUMMA<0 S SUMMA=-SUMMA + S %X=+$P(SUMMA,".",1),SUMMAP="",VV=0 + ;I %X=0 S SUMMAP="ноль рублей" + I %X=0 S SUMMAP="ноль " + I %X>0 D PRUBL + S V2=$E(%X,$L(%X)-1),V3=$E(%X,$L(%X)) + I V3=1,V2'=1 S SUMMAP=SUMMAP_" рубль",VV=1 + I ((V3=2)!(V3=3)!(V3=4))&(V2'=1) S SUMMAP=SUMMAP_" рубля",VV=1 + I ((V3=1)!(V3=2)!(V3=3)!(V3=4))&(V2=1) S SUMMAP=SUMMAP_" рублей",VV=1 + I V3>4 S SUMMAP=SUMMAP_" рублей",VV=1 + I VV=0 S SUMMAP=SUMMAP_" рублей" + S %X=$P(SUMMA,".",2) I %X="" S %X="00" + I %X?1N S %X=%X_"0",(V1,V)="0" + I %X?2N S V1=$E(%X,1,1),V=$E(%X,2,2) +R1 I (V="1")&(V1'="1") S SUMMAP=SUMMAP_" "_%X_" копейка" + I ((V="2")!(V="3")!(V="4"))&(V1'="1") S SUMMAP=SUMMAP_" "_%X_" копейки" + I ((V'="1")&(V'="2")&(V'="3")&(V'="4"))!(V1="1") S SUMMAP=SUMMAP_" "_%X_" копеек" + I $E(SUMMAP)=" " S SUMMAP=$E(SUMMAP,2,255) + S SUMMAP=$TR($E(SUMMAP),"одтчпшсвн","ОДТЧПШСВН")_$E(SUMMAP,2,255) +END0 K %X,%X0,%X1,R0,R1 + Q (SUMMAP) ;1 + ;- +PRUBL ; Euro + D PMILR,PMILE,PtYS,PEDIN + Q ;Added + ;- +PMILR ;BILLION + S %X0=%X\1000000000 Q:%X0=0 ;### + D PSoT,PDES + +RRR3 S SUMMAP=SUMMAP_" миллиард"_$S(%X0#100=0:"ов",%X0#100>10&(%X0#100<21):"ов",%X0#10>1&(%X0#10<5):"а",%X0#10=1:"",1:"ов")_" " + K R3 + Q ;PMILR + ;- +PMILE ;Millions + ;S %X0=%X\1000000 Q:%X0=0 ;### + S %X0=%X#1000000000\1000000 Q:%X0=0 ;### + D PSoT,PDES + +R3 S SUMMAP=SUMMAP_" миллион"_$S(%X0#100=0:"ов",%X0#100>10&(%X0#100<21):"ов",%X0#10>1&(%X0#10<5):"а",%X0#10=1:"",1:"ов")_" " + K R3 + Q ;PMILE + ;- +PtYS ;THOUSAND + S %X0=%X#1000000\1000 Q:%X0=0 ;### + D PSoT,PDES + S %X1=$E(SUMMAP,$L(SUMMAP)-2,$L(SUMMAP)) + I %X1="ва " S SUMMAP=$E(SUMMAP,1,$L(SUMMAP)-3)_"ве " + I %X1="ин " S SUMMAP=$E(SUMMAP,1,$L(SUMMAP)-3)_"на " +QQ S SUMMAP=SUMMAP_"тысяч"_$S(%X0#100=11:"",%X0#100=12:"",%X0#100=13:"",%X0#100=14:"",%X0#10=1:"а",%X0#10>1&(%X0#10<5):"и",1:"")_" " + K R4,R5,R6 + Q ;PtYS + ;- +PEDIN ;UNITS IN BREAKDOWN + S %X0=%X#1000 Q:%X0=0 ;### + D PSoT,PDES + Q ;PtDIN + ;- +PSoT ;HUNDREDS + S %X1=%X0\100 Q:%X1=0 ;### +R7 S S1="сто" +R8 S S2="двести" +R9 S S3="триста" +R10 S S4="четыреста" +R11 S S5="пятьсот" +R12 S S6="шестьсот" +R13 S S7="семьсот" +R14 S S8="восемьсот" +R15 S S9="девятьсот" + S SUMMAP=SUMMAP_$S(%X1=1:S1,%X1=2:S2,%X1=3:S3,%X1=4:S4,%X1=5:S5,%X1=6:S6,%X1=7:S7,%X1=8:S8,%X1=9:S9)_" " + K S1,S2,S3,S4,S5,S6,S7,S8,S9 + Q ;PSoT + ;- +PDES ;TENS + S %X1=%X0#100\10 Q:%X=0 ;### + I %X1=1 D PDC Q ;### +R17 S D2="двадцать" +R18 S D3="тридцать" +R19 S D4="сорок" +R20 S D5="пятьдесят" +R21 S D6="шестьдесят" +R22 S D7="семьдесят" +R23 S D8="восемьдесят" +R24 S D9="девяносто" + S SUMMAP=SUMMAP_$S(%X1=2:D2,%X1=3:D3,%X1=4:D4,%X1=5:D5,%X1=6:D6,%X1=7:D7,%X1=8:D8,%X1=9:D9,1:"")_" " + K D2,D3,D4,D5,D6,D7,D8,D9 + D PoDIN + Q ;PDES + ;- +PDC ; + S %X1=%X0#10 +R25 S F0="десять" +R26 S F1="одиннадцать" +R27 S F2="двенадцать" +R28 S F3="тринадцать" +R29 S F4="четырнадцать" +R30 S F5="пятнадцать" +R31 S F6="шестнадцать" +R32 S F7="семнадцать" +R33 S F8="восемнадцать" +R34 S F9="девятнадцать" + S SUMMAP=SUMMAP_$S(%X1=0:F0,%X1=1:F1,%X1=2:F2,%X1=3:F3,%X1=4:F4,%X1=5:F5,%X1=6:F6,%X1=7:F7,%X1=8:F8,%X1=9:F9) + K F0,F1,F2,F3,F4,F5,F6,F7,F8,F9 + Q ;PDC + ;- +PoDIN ;UNITS + S %X1=%X0#10 I %X1=0 Q ;### + S SUMMAP=SUMMAP_$S(%X1=1:"один",%X1=2:"два",%X1=3:"три",%X1=4:"четыре",%X1=5:"пять",%X1=6:"шесть",%X1=7:"семь",%X1=8:"восемь",%X1=9:"девять",1:"")_" " + K E1,E2,E3,E4,E5,E6,E7,E8,E9 + Q ;PoDIN +} + +} diff --git a/README.md b/README.md index 3194131..3befeb6 100644 --- a/README.md +++ b/README.md @@ -52,3 +52,36 @@ ERROR #420: Lang fr not exists 2018-08-07 [Version 1.1](https://github.com/KurroLopez/CosNumberTranslate/blob/master/Version/CosNumberTranslation_v1.1.xml) - Russian translate 2018-06-29 [Version 1.0](https://github.com/KurroLopez/CosNumberTranslate/blob/master/Version/CosNumberTranslation_v1.0.xml) - Initial version + +## Docker +Container build and start runs ALL installation steps. +It is immedeatly ready for use as decsribed +example.script provides quick check from terminal + +### Prerequisites +Make sure you have [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [Docker desktop](https://www.docker.com/products/docker-desktop) installed. +### Installation +Clone/git pull the repo into any local directory +``` +$ git clone https://github.com/rcemper/PR_CosNumberTranslate.git +``` +``` +$ docker compose up -d && docker compose logs -f +``` +Quick REST access to MASTER: +http://localhost:42773/synchmaster/rest/v1/customers + +Quick REST access to CLIENT: +http://localhost:42773/synchclient/rest/v1/employees + + +To open IRIS Terminal do: +``` +$ docker-compose exec iris iris session iris +USER> +``` +or using **WebTerminal** +http://localhost:42773/terminal/ + +To access IRIS System Management Portal +http://localhost:42773/csp/sys/UtilHome.csp diff --git a/ascript.sh b/ascript.sh new file mode 100644 index 0000000..7f0f074 --- /dev/null +++ b/ascript.sh @@ -0,0 +1,4 @@ +cd /home/irisowner/dev +iris view +iris session iris < iris.script +exit 0 \ No newline at end of file diff --git a/demo.script b/demo.script new file mode 100644 index 0000000..7e8474f --- /dev/null +++ b/demo.script @@ -0,0 +1,17 @@ +write ##class(NumberTranslate.NumberTranslate).GetText(123,.tSc) +;; one hundred and twenty-three +write ##class(NumberTranslate.NumberTranslate).GetText(123,.tSc,"es") +;; ciento veintitres +write ##class(NumberTranslate.NumberTranslate).GetText(123,.tSc,"ca") +;; cent vint-i-tres +write ##class(NumberTranslate.NumberTranslate).GetText(123,.tSc,"ru") +;; Сто двадцать три +write ##class(NumberTranslate.NumberTranslate).GetText(1000000000,.tSc,"en",1) +;; one billion +write ##class(NumberTranslate.NumberTranslate).GetText(1000000000,.tSc,"en",0) +;; one thousand millions +write ##class(NumberTranslate.NumberTranslate).GetText(1000000000000,.tSc,"en",1) +;; one trillion +write ##class(NumberTranslate.NumberTranslate).GetText(1000000000000,.tSc,"en",0) +;; one billion +write diff --git a/dev.md b/dev.md new file mode 100644 index 0000000..080011f --- /dev/null +++ b/dev.md @@ -0,0 +1,117 @@ +# useful commands +## clean up docker +use it when docker says "There is no space left on device". It will remove built but not used images and other temporary files. +``` +docker system prune -f +``` + +``` +docker rm -f $(docker ps -qa) +``` + +## build container with no cache +``` +docker-compose build --no-cache --progress=plain +``` +## start iris container +``` +docker-compose up -d +``` + +## open iris terminal in docker +``` +docker exec iris iris session iris -U IRISAPP +``` + + +## import objectscirpt code + +do $System.OBJ.LoadDir("/home/irisowner/dev/src","ck",,1) +## map iris key from Mac home directory to IRIS in container +- ~/iris.key:/usr/irissys/mgr/iris.key + +## install git in the docker image +## add git in dockerfile +USER root +RUN apt update && apt-get -y install git + +USER ${ISC_PACKAGE_MGRUSER} + + +## install docker-compose +``` +sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + +sudo chmod +x /usr/local/bin/docker-compose + +``` + +## load and test module +``` + +zpm "load /home/irisowner/dev" + +zpm "test dc-sample" +``` + +## select zpm test registry +``` +repo -n registry -r -url https://test.pm.community.intersystems.com/registry/ -user test -pass PassWord42 +``` + +## get back to public zpm registry +``` +repo -r -n registry -url https://pm.community.intersystems.com/ -user "" -pass "" +``` + +## export a global in runtime into the repo +``` +d $System.OBJ.Export("GlobalD.GBL","/irisrun/repo/src/gbl/GlobalD.xml") +``` + +## create a web app in dockerfile +``` +zn "%SYS" \ + write "Create web application ...",! \ + set webName = "/csp/irisweb" \ + set webProperties("NameSpace") = "IRISAPP" \ + set webProperties("Enabled") = 1 \ + set webProperties("CSPZENEnabled") = 1 \ + set webProperties("AutheEnabled") = 32 \ + set webProperties("iKnowEnabled") = 1 \ + set webProperties("DeepSeeEnabled") = 1 \ + set sc = ##class(Security.Applications).Create(webName, .webProperties) \ + write "Web application "_webName_" has been created!",! +``` + + + +``` +do $SYSTEM.OBJ.ImportDir("/opt/irisbuild/src",, "ck") +``` + + +### run tests described in the module + +IRISAPP>zpm +IRISAPP:zpm>load /irisrun/repo +IRISAPP:zpm>test package-name + +### install ZPM with one line + // Install ZPM + set $namespace="%SYS", name="DefaultSSL" do:'##class(Security.SSLConfigs).Exists(name) ##class(Security.SSLConfigs).Create(name) set url="https://pm.community.intersystems.com/packages/zpm/latest/installer" Do ##class(%Net.URLParser).Parse(url,.comp) set ht = ##class(%Net.HttpRequest).%New(), ht.Server = comp("host"), ht.Port = 443, ht.Https=1, ht.SSLConfiguration=name, st=ht.Get(comp("path")) quit:'st $System.Status.GetErrorText(st) set xml=##class(%File).TempFilename("xml"), tFile = ##class(%Stream.FileBinary).%New(), tFile.Filename = xml do tFile.CopyFromAndSave(ht.HttpResponse.Data) do ht.%Close(), $system.OBJ.Load(xml,"ck") do ##class(%File).Delete(xml) + + + + +docker run --rm --name iris-sql -d -p 9091:1972 -p 9092:52773 -e IRIS_PASSWORD=demo -e IRIS_USERNAME=demo intersystemsdc/iris-community + + +docker run --rm --name iris-ce -d -p 9091:1972 -p 9092:52773 -e IRIS_PASSWORD=demo -e IRIS_USERNAME=demo intersystemsdc/iris-community -a "echo 'zpm \"install webterminal\"' | iriscli" + + + +docker run --rm --name iris-sql -d -p 9092:52773 containers.intersystems.com/intersystems/iris-community:2023.1.0.229.0 + + +docker run --rm --name iris-ce -d -p 9092:52773 containers.intersystems.com/intersystems/iris-community:2023.1.0.229.0 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..eea062d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.6' +services: + iris: + image: intersystemsdc/iris-community + restart: always + command: -a /home/irisowner/dev/ascript.sh + + ports: + - 41773:1972 + - 42773:52773 + volumes: + - ./:/home/irisowner/dev diff --git a/iris.script b/iris.script new file mode 100644 index 0000000..1820561 --- /dev/null +++ b/iris.script @@ -0,0 +1,17 @@ + zn "%SYS" + + // Unexpire passwords and set up passwordless mode to simplify dev use. + do ##class(Security.Users).UnExpireUserPasswords("*") + zpm "install passwordless" + + zn "USER" + // Create /_vscode web app to support intersystems-community.testingmanager VS Code extension + zpm "install vscode-per-namespace-settings" + zpm "install webterminal" + + // this should be the place for individual application code. + + do $system.OBJ.Load("/home/irisowner/dev/Version/CosNumberTranslation_v1.1.2.xml","ck") + zpm "list" + halt +