Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

crowdin-config.js 1.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  1. const config = require('../helpers/crowdin-config').read()
  2. const { loadPages } = require('../../lib/pages')
  3. const ignoredPagePaths = config.files[0].ignore
  4. const ignoredDataPaths = config.files[2].ignore
  5. describe('crowdin.yml config file', () => {
  6. jest.setTimeout(60 * 1000)
  7. let pages
  8. beforeAll(async (done) => {
  9. pages = await loadPages()
  10. done()
  11. })
  12. test('has expected file structure', async () => {
  13. expect(config.files.length).toBe(3)
  14. expect(config.files[0].source).toBe('/content/**/*.md')
  15. expect(config.files[0].ignore).toContain('/content/README.md')
  16. })
  17. test('ignores all Early Access paths', async () => {
  18. expect(ignoredPagePaths).toContain('/content/early-access')
  19. expect(ignoredDataPaths).toContain('/data/early-access')
  20. })
  21. test('ignores all hidden pages', async () => {
  22. const hiddenPages = pages
  23. .filter(page => page.hidden && page.languageCode === 'en')
  24. .map(page => `/content/${page.relativePath}`)
  25. const overlooked = hiddenPages.filter(page => !isIgnored(page, ignoredPagePaths))
  26. const message = `Found some hidden pages that are not yet excluded from localization.
  27. Please copy and paste the lines below into the \`ignore\` section of /crowdin.yml: \n\n"${overlooked.join('",\n"')}"`
  28. // This may not be true anymore given the separation of Early Access docs
  29. // expect(hiddenPages.length).toBeGreaterThan(0)
  30. expect(ignoredPagePaths.length).toBeGreaterThan(0)
  31. expect(overlooked, message).toHaveLength(0)
  32. })
  33. })
  34. // file is ignored if its exact filename in the list,
  35. // or if it's within an ignored directory
  36. function isIgnored (filename, ignoredPagePaths) {
  37. return ignoredPagePaths.some(ignoredPath => {
  38. const isDirectory = !ignoredPath.endsWith('.md')
  39. return ignoredPath === filename || (isDirectory && filename.startsWith(ignoredPath))
  40. })
  41. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...