Skip to content

Multi lingual text - #1

Draft
mikklee wants to merge 10 commits into
developmentfrom
multi-lingual-text
Draft

Multi lingual text#1
mikklee wants to merge 10 commits into
developmentfrom
multi-lingual-text

Conversation

@mikklee

@mikklee mikklee commented Jun 22, 2026

Copy link
Copy Markdown
Owner

NOTE! This PR has a lot of lines mainly due to adding Jest and extensive tests.

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

FreeTubeApp#2590

Description

Implements an experimental feature that let's you override the lang setting for the Innertube client:

  • Adds a selector in subscribed channel view for the preferred language
    • WIP: Working on implementing this outside of subscribed channels. Feedback would be appreciated here.
    • WIP: Will probably move the selector somewhere else in the UI
  • Adds a utility for detecting and parsing relative time in most Youtube supported languages
    • Uses a search-tree (Trie) to quickly determine what kind of exponent the relative time is
      • parseRelativeTime: Detects and parses the relative time
      • isRelativeTime: A slightly more performant function used to determine if a given text is relative time or not
      • formatRelativeTime: This can be used to parse seconds into english relative time again. Will probably remove this as there already is a util for this in the project.
    • Unsupported languages will cause titles to fallback to the original titles
    • Feature must be enabled under experimental features. It can potentially break stuff. Currently working on ironing out potential issues.

Screenshots

Will be added soon

Testing

Tests

I have added extensive tests for the relative time logic. This however adds more dev dependencies, so I'd also like feedback on whether this is okay to contribute.

Testing the feature

  1. Go into Settings > Experimental
  2. Enable Experimental Multilingual Text Parsing
  3. Subscribe to a channel you know is using AI translations for titles, and enter it.
  4. Change the preffered language using the selector in the top-right corner
  5. Refresh the page (WIP, will have to auto-refresh on change)

Desktop

  • OS: macOS Tahoe
  • OS Version: 26.5
  • FreeTube version: Developer branch

Additional context

This is still work in progress (WIP). Need to iron out potential issues.
Feedback is appreciated.

Alternatives

This is based on the logic I used for my own youtube client, so I have considered other alternatives.
Feel free to explore them however.

  • Map per-language settings in the existing language files and load them by preference.
    • May be cleaner, but potentially adds a lot of boiler plate.
  • Make the request twice with en lang, and then with the preferred lang.
    • Youtube uses continuation tokens for fetching more videos and these are different per lang, and can return varying lists of videos. This is not straight forward.
  • Make the request with a supported language that does not support AI translations
    • Only allows you to get the original titles.
    • I don't remember why, but it was unreliable.

Tasks remaning:

  • UI placement of selector
  • Lang selection under search (I was thinking you could search with loc:jp for instance)
  • Deal with view count (Yes, this is also returned in whatever language you request with), and potentially other issues.
  • Rebase commits to follow a fixed description scheme? Freetube uses a bit different style than what I am used to, so I ended up making some mistakes here. I assume if this is merged, it will be squashed anyway.

Michael Thomas Lee added 10 commits May 24, 2026 12:52
This should support most languages available on Youtube
Enables an option to parse relative time strings in
video metadata for non-English languages.
Makes it easier to see that something went wrong during the parsing.
When null, default to 1. This is for edge cases like 'A year ago'.
This was a stowaway from a previous commit
No point in those being part of the separate hanzi/kanji-relevant logic

Also removes some ranges from the isHan check that were not relevant to
that function to begin with. Eg. Thai.
Adds isRelativeTime helper for multilingual support

This function detects relative time strings across multiple languages..
It replaces the `endsWith('ago')` check in the local API when the
experimental multilingual setting is enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant