Skip to content

Commit

Permalink
add resource bundle for engine strings
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-chwedczuk committed Nov 16, 2024
1 parent add5910 commit c0c5744
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 0 deletions.
2 changes: 2 additions & 0 deletions engine/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
exports mscalc.engine.ratpack;
exports mscalc.engine;
exports mscalc.engine.commands;

requires java.xml;
}
110 changes: 110 additions & 0 deletions engine/src/main/resources/mscalc/engine/calc-engine_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#en-US/CEngineStrings.resw
#Sat Nov 16 18:46:51 CET 2024
10=Rsh
100=Invalid input
101=Result is undefined
105=Not enough memory
107=Overflow
108=Result not defined
11=\u00F7
118=Result not defined
119=Overflow
12=\u00D7
120=Overflow
13=+
14=-
15=Mod
16=yroot
17=^
18=Int
19=RoL
2=CE
20=RoR
21=NOT
22=sin
23=cis
24=tan
25=sinh
26=cosh
27=tanh
28=ln
29=log
30=\u221A
35=dms
37=10^
38=%
4=.
40=Pi
41=\=
47=Exp
48=(
49=)
6=AND
66=frac
67=sin\u2080
68=cos\u2080
69=tan\u2080
7=OR
70=sin\u2080\u207B\u00B9
71=cos\u2080\u207B\u00B9
72=tan\u2080\u207B\u00B9
73=sin\u1D63
74=cos\u1D63
75=tan\u1D63
76=sin\u1D63\u207B\u00B9
77=cos\u1D63\u207B\u00B9
78=tan\u1D63\u207B\u00B9
79=sin\u2089
8=XOR
80=cos\u2089
81=tan\u2089
82=sin\u2089\u207B\u00B9
83=cos\u2089\u207B\u00B9
84=tan\u2089\u207B\u00B9
85=sinh\u207B\u00B9
86=cosh\u207B\u00B9
87=tanh\u207B\u00B9
88=e^
89=10^
9=Lsh
90=\u221A
91=sqr
92=cube
94=fact
95=1/
96=degrees
97=negate
99=Cannot divide by zero
Abs=abs
Ceil=ceil
CotDeg=cot\u2080
CotGrad=cot\u2089
CotRad=cot\u1D63
Coth=coth
CscDeg=csc\u2080
CscGrad=csc\u2089
CscRad=csc\u1D63
Csch=csch
CubeRoot=cuberoot
Floor=floor
InverseCotDeg=cot\u2080\u207B\u00B9
InverseCotGrad=cot\u2089\u207B\u00B9
InverseCotRad=cot\u1D63\u207B\u00B9
InverseCoth=coth\u207B\u00B9
InverseCscDeg=csc\u2080\u207B\u00B9
InverseCscGrad=csc\u2089\u207B\u00B9
InverseCscRad=csc\u1D63\u207B\u00B9
InverseCsch=csch\u207B\u00B9
InverseSecDeg=sec\u2080\u207B\u00B9
InverseSecGrad=sec\u2089\u207B\u00B9
InverseSecRad=sec\u1D63\u207B\u00B9
InverseSech=sech\u207B\u00B9
LogBaseY=log base
Nand=NAND
Nor=NOR
ProgrammerMod=%
SecDeg=sec\u2080
SecGrad=sec\u2089
SecRad=sec\u1D63
Sech=sech
TwoPowX=2^
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package mscalc.utils;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.util.Properties;

public class DotNetResources2JavaResourceBundle {
@Test
@Disabled
void doIt() {
try {
XMLInputFactory factory = XMLInputFactory.newInstance();
XMLStreamReader reader = factory.createXMLStreamReader(new FileReader("/Users/mc/github/calculator/src/Calculator/Resources/en-US/CEngineStrings.resw"));

Properties resourceBundleData = new Properties();
String key = null, value = null;

while (reader.hasNext()) {
int event = reader.next();
switch (event) {
case XMLStreamConstants.START_ELEMENT:
if ("data".equals(reader.getLocalName())) {
key = reader.getAttributeValue(null, "name");
} else if ("value".equals(reader.getLocalName())) {
value = reader.getElementText();

if (key != null && value != null) {
resourceBundleData.setProperty(key, value);
System.out.println("Key: " + key + ", value: " + value);
}

key = value = null;
}
break;
}
}

try (FileOutputStream outputStream = new FileOutputStream("mscalc/engine/calc-engine_en.properties")) {
resourceBundleData.store(outputStream, "en-US/CEngineStrings.resw");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

0 comments on commit c0c5744

Please sign in to comment.