Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch individual translation archives for cache based on the environment variable configuration #217

Closed
kbdharun opened this issue Sep 15, 2023 · 3 comments

Comments

@kbdharun
Copy link
Member

As specified in Client Specification 2.0

If appropriate, it is RECOMMENDED that clients implement a cache of pages. If implemented, clients MUST download the entire archive either as a whole from https://tldr.sh/assets/tldr.zip (Which redirects to https://raw.githubusercontent.com/tldr-pages/tldr-pages.github.io/main/assets/tldr.zip) or download language-specific translation archives in the format https://tldr.sh/assets/tldr-pages.{{language-code}}.zip (Which redirects to https://raw.githubusercontent.com/tldr-pages/tldr-pages.github.io/main/assets/tldr-pages.{{language-code}}.zip), along with the archive for English from https://tldr.sh/assets/tldr-pages.zip (It redirects to https://raw.githubusercontent.com/tldr-pages/tldr-pages.github.io/main/assets/tldr-pages.zip).

Caching SHOULD be done according to the user's language configuration (if any), to not waste unneeded space for unused languages. Additionally, clients MAY automatically update the cache regularly.

So, we need to update the client behaviour to work with fetching only the specified language's archive when fetching based on configuration or via the tldr <page> --language <language-code> command, we can include English by default as a fallback.

@kbdharun kbdharun changed the title Fetch individual translation archives based on the language environment variable configuration Fetch individual translation archives for cache based on the language environment variable configuration Sep 15, 2023
@kbdharun kbdharun changed the title Fetch individual translation archives for cache based on the language environment variable configuration Fetch individual translation archives for cache based on the environment variable configuration Sep 15, 2023
@kbdharun kbdharun pinned this issue Sep 15, 2023
@SaurabhDRao
Copy link
Contributor

Hello! Can I take this up ?

Below are the changes that needs to be done right ?

  • if a language is set, then fetch only the data for that particular language from the respective language archive location.
  • if no language is set, then fetch the english archive as default.

@kbdharun
Copy link
Member Author

kbdharun commented Oct 1, 2023

Hello! Can I take this up ?

Sure

Below are the changes that needs to be done right ?

  • if a language is set, then fetch only the data for that particular language from the respective language archive location.
  • if no language is set, then fetch the english archive as default.

Yes, if a language is set (in the environment variable) only the language and English translation archive must be fetched and when a page isn't translated the client needs to fall back to the English page.

@SaurabhDRao
Copy link
Contributor

I have added change for pulling the language specific archives into cache. (#218)

But I noticed that the fallback on en is already present. In the get_page function, there is a call to get a list of all languages where it is attaching the default language (en) at the end. Let me know if I am missing something.

kbdharun pushed a commit that referenced this issue Feb 23, 2024
* Fetch individual translation archives for cache based on the environment variable configuration (#217)

* download cache for all user preferred languages

* reduced chars per line to pass linter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants