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

Added command line parameter to not create zim for languages with variants #206

Merged
merged 2 commits into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ npm i && npm start
The above will eventually output a ZIM file to ```dist/```

## Command line arguments
`--withoutLanguageVariants` uses to exclude languages with County variant. For example `en_ca` will not be present in zim with this argument.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that not "en-CA"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the phet site, we are getting "en_CA"


Available only on GET step:
```bash
--withoutLanguageVariants ...
```

Available on GET and EXPORT steps only:
```bash
--includeLanguages lang_1 [lang_2] [lang_3] ...
Expand Down
5 changes: 4 additions & 1 deletion steps/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { hideBin } from 'yargs/helpers'

dotenv.config()

const { argv } = yargs(hideBin(process.argv)).array('includeLanguages').array('excludeLanguages')
const { argv } = yargs(hideBin(process.argv)).boolean('withoutLanguageVariants').array('includeLanguages').array('excludeLanguages')

const failedDownloadsCountBeforeStop = 10
const outDir = 'state/get/'
Expand Down Expand Up @@ -81,6 +81,9 @@ const fetchLanguages = async (): Promise<void> => {
rows.forEach((item) => {
const url = $(item).find('td.list-highlight-background:first-child a').attr('href')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix problems

const slug = /locale=(.*)$/.exec(url)?.pop()
if (argv.withoutLanguageVariants && slug.includes('_')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a log entry

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not be based on the slug, but on the lang. This is not robust.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slug it just a variable name. It is filled from the locale part of the URL.
All other steps and functions use the value from this variable to define the language.

return
}
const name = $(item).find('td.list-highlight-background:first-child a span').text()

const nativeLangName = ISO6391.getNativeName(slug)
Expand Down