Skip to content

Commit

Permalink
Merge pull request #206 from openzim/create-zim-without-language-vari…
Browse files Browse the repository at this point in the history
…ants

Added command line parameter to not create zim for languages with variants
  • Loading branch information
kelson42 authored Mar 5, 2023
2 parents 0efd7ba + 25ee244 commit 188cdb2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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 Country variant. For example `en_CA` will not be present in zim with this argument.

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

Available on GET and EXPORT steps only:
```bash
--includeLanguages lang_1 [lang_2] [lang_3] ...
Expand Down
6 changes: 5 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,10 @@ const fetchLanguages = async (): Promise<void> => {
rows.forEach((item) => {
const url = $(item).find('td.list-highlight-background:first-child a').attr('href')
const slug = /locale=(.*)$/.exec(url)?.pop()
if (argv.withoutLanguageVariants && slug.includes('_')) {
log.info(`Skipping ${slug} language`)
return
}
const name = $(item).find('td.list-highlight-background:first-child a span').text()

const nativeLangName = ISO6391.getNativeName(slug)
Expand Down

0 comments on commit 188cdb2

Please sign in to comment.