Giter Site home page Giter Site logo

Comments (13)

Razzmatazzz avatar Razzmatazzz commented on July 30, 2024 1

This regex isn't being run every time there's an API call; it's being run when item prices are updated and data is uploaded to the cloudflare KVs for the API to use:
https://github.com/the-hideout/tarkov-data-manager/blob/9e5472004784624c75e3ee0b3a83ec1598586623/src/tarkov-data-manager/jobs/update-item-cache.js#L471-L477

from tarkov-api.

Shebuka avatar Shebuka commented on July 30, 2024

To add: the FleaMarket name is all CAPS, I think it must be like others with only the first letter capital

from tarkov-api.

GrantBirki avatar GrantBirki commented on July 30, 2024

I'm not sure if there is a historical reason for why we have normalizedName: String excluded from the FleaMarket item. If there isn't a good reason for why this is missing today, then I agree and we should absolutely add it! :)

As for the type name, I think it is correct being FleaMarket. Looking at the schema, many other types have this same case definition. See the examples below:

image

image

image

from tarkov-api.

Shebuka avatar Shebuka commented on July 30, 2024

Apologise for wording it wrongly, it's all caps what is returned in the name field by the API, I see "name": "БАРАХОЛКА",
Screenshot 2022-07-10 at 10 21 33

from tarkov-api.

Shebuka avatar Shebuka commented on July 30, 2024

p.s. Question: if the flea market is disabled do we still get the flea market in sellto/buyfrom but with enabled: false?

from tarkov-api.

Razzmatazzz avatar Razzmatazzz commented on July 30, 2024

We can add normalizedName to the FleaMarket type. It's missing because normalizedName was a recent addition to the traders and it just wasn't added to the FleaMarket type at the time.

The flea market name being all in caps is due to the lowercase regex not properly picking up Cyrillic uppercase characters. Is барахолка a more appropriate capitalization?

from tarkov-api.

Shebuka avatar Shebuka commented on July 30, 2024

The flea market name being all in caps is due to the lowercase regex not properly picking up Cyrillic uppercase characters. Is барахолка a more appropriate capitalization?

yes, but with the first letter capital like for all other traders, Барахолка

from tarkov-api.

Razzmatazzz avatar Razzmatazzz commented on July 30, 2024

This is the updated code that's being used to convert the uppercase "FLEA MARKET" to "Flea Market" for all languages:

UPPERCASE_STRING.replace(/(?<!\b)([A-ZА-Я])/g, substr => {
    return substr.toLowerCase();
});

What it's supposed to do is capture any upper case letters that aren't at the beginning of a word and convert them to lower case. I added А-Я to capture Cyrillic upper case characters, but it seems to also be capturing the first upper case letter that's at the beginning of the Russian word.

from tarkov-api.

Razzmatazzz avatar Razzmatazzz commented on July 30, 2024

I think I figured it out to just return the match if it's at index 1: Барахолка
Apparently issue stems from unicode characters, and the pattern to get a correct match is (?<!^|\s)([A-ZА-Я])

from tarkov-api.

Shebuka avatar Shebuka commented on July 30, 2024

As we load these names for a particular lang can't we simply update the translation to the correct case? (just want to understand how it works, we have Therapist and Терапевт in the correct case, why not the Flea?)

from tarkov-api.

Shebuka avatar Shebuka commented on July 30, 2024

I was just testing other languages for Flea Market translations and in cz it's returned as BleŠÍ Trh but google returns Bleší Trh (in the first word the last two letters are not capital) and in fr MarchÉ, so I suppose the regex is not working for any language other than one that use only basic Latin chars

from tarkov-api.

Razzmatazzz avatar Razzmatazzz commented on July 30, 2024

As we load these names for a particular lang can't we simply update the translation to the correct case? (just want to understand how it works, we have Therapist and Терапевт in the correct case, why not the Flea?)

That's exactly what we're doing. In the localization files we have, the only string for "Flea Market" we have is in all upper case characters, so it has to be converted. Digging a bit more, I believe the proper regex to match all uppercase unicode characters that aren't at the start of a word is /(?<!^|\s)\p{Lu}+/gu.

from tarkov-api.

Shebuka avatar Shebuka commented on July 30, 2024

This regex seems to work perfectly. 👍

But why we can't update the localization files directly and save regexs CPU cycles?

from tarkov-api.

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.