Comments (9)
Sounds like this should be part of .tr() to me
from unciv.
Sounds like this should be part of .tr() to me
Lazy me says, modify String.tr()
in such a way that [value]
parsing detects numbers and formats them with NumberFormat.format()
from unciv.
Lazy me says, modify
String.tr()
in such a way that[value]
parsing detects numbers and formats them withNumberFormat.format()
Although not sure if this would account for all cases.
from unciv.
Ok, trying to understand Translations.kt
. It is surely a piece of sophisticated artwork (maybe?). Parsing code always ends up like this huh? Maybe time to learn how to write lexers and language processing to better write such stuff for myself. But not now I guess.
from unciv.
Ok, after some analysis of how translations are actually being used, I can see that any number passed to String.fillPlaceholders()
is being converted to string with Number.toString()
beforehand, which, unfortunately we cannot override. That leaves us with some possible options:
- Check if strings being passed to
String.fillPlaceholders()
are numbers and if they are, convert them to translated numbers. - Implement
Number.toTranslatedString()
and deprecate the usage ofNumber.toString()
somehow and replace all existing usage ofNumber.toString()
toNumber.toTranslatedString()
.
These are the options that I can think of currently.
from unciv.
tr does a lot of things - breaks text down to individual components, finds matching translation tempates, etc.
We don't need any of that, we just need the "simple" case of "translate this thing directly"
You see at the end of tr() we have lines like "if it's stats do A, if it's a stat do B"? That's where we take individual parameters and handle them in special ways
So all we need to do there is add "if this is a number, show this as a number in this language"
I split tr() into subfunctions - what you need to worry about is translateIndividualWord()
from unciv.
So you want me to regex match numbers from string, then convert them to numbers and then again convert them back to string with NumberFormat
?
from unciv.
Getting `java.lang.NullPointerException: Cannot invoke "java.util.Locale.stripExtensions()" because "locale" is null
from unciv.
Ok, fixed now. But some new issues. See #11898
from unciv.
Related Issues (20)
- City state ideas HOT 7
- World wrap disappears in games saved in 4.12.15 - SOLVED in 4.12.16 HOT 9
- Feature request: AIs sometimes have difficulty with settler + escort vs. barbarians for up to three eras(!) HOT 3
- Tutorials json file getting flagged as error in mod checker
- Workers spamming forts HOT 1
- Science points drops from +22 to +1 on Next Turn with no interim changes HOT 2
- Crash on next turn HOT 1
- Feature request: Hi
- Saves seem broken when saving from an old save file HOT 4
- Multiplayer Next Turn Crash in v4.12.18 - SOLVED 4.12.18-patch1 HOT 5
- Feature request: better music system HOT 2
- Multiplayer Next Turn Crash in v4.12.18 - SOLVED 4.12.18-patch1 HOT 1
- ошибка при пропускании хода происходящая с 295 по 390 ход HOT 2
- Ruins showing up in water around Rock of Gibraltar
- AI confused about non-settling HOT 7
- a bug HOT 6
- Feature request: fix strategic balance
- Zip link is invalid HOT 7
- Feature request: Mod request? HOT 3
- Invalid mod archive structure HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unciv.