Firstly, I apologise if this was already asked. I’m not familiar with this website and the search seems quite glitchy.

Anyway, I’m trying to make a generator that will (amongst other things) create a basic Chinese ‘name’ in pinyin. Without tones is no issue. With tones, well, there’s a problem.

I can get all lowercase outputs just fine, and when the first letter is not accented, its also just fine. But if the first is accented, the output skips the accented letter and then capitalizes the SECOND letter.

For example,

tè áobǎ

Becomes this:

Tè áObǎ

When I actually want this:

Tè Áobǎ

I’m sure there is probably some fancy pants way to check if a letter is the first in the word and then substitute for the right letter, but, I am new to perchance, and my current searching hasn’t yielded any results on how this could be done.

Something like checking the first letter of the sentence case against a list of symbols, then using the substitute? (I’m not a coder, and I don’t know how to do this!)

my current code, barely worth even sharing:

output = [sentence]

sentence
  [pinyin.sentenceCase] [pinyin.sentenceCase][pinyin]
  • VioneT@lemmy.worldM
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 months ago

    Ah, .sentenceCase is used to only capitalize the 1st letter of the sentence. You might want to use .titleCase to capitalize each word.

    • cass24@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 months ago

      sksksk something so simple-- Thank you so much! It is working as intended now. ♥