Giter Club home page Giter Club logo

Comments (9)

yairm210 avatar yairm210 commented on August 23, 2024

Sounds like this should be part of .tr() to me

from unciv.

touhidurrr avatar touhidurrr commented on August 23, 2024

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.

touhidurrr avatar touhidurrr commented on August 23, 2024

Lazy me says, modify String.tr() in such a way that [value] parsing detects numbers and formats them with NumberFormat.format()

Although not sure if this would account for all cases.

from unciv.

touhidurrr avatar touhidurrr commented on August 23, 2024

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.

touhidurrr avatar touhidurrr commented on August 23, 2024

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:

  1. Check if strings being passed to String.fillPlaceholders() are numbers and if they are, convert them to translated numbers.
  2. Implement Number.toTranslatedString() and deprecate the usage of Number.toString() somehow and replace all existing usage of Number.toString() to Number.toTranslatedString().

These are the options that I can think of currently.

from unciv.

yairm210 avatar yairm210 commented on August 23, 2024

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.

touhidurrr avatar touhidurrr commented on August 23, 2024

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.

touhidurrr avatar touhidurrr commented on August 23, 2024

Getting `java.lang.NullPointerException: Cannot invoke "java.util.Locale.stripExtensions()" because "locale" is null

from unciv.

touhidurrr avatar touhidurrr commented on August 23, 2024

Ok, fixed now. But some new issues. See #11898

from unciv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.