-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1286 from visualize-admin/fix/allow-localized-lan…
…ding-pages feat: Landing page can be localized
- Loading branch information
Showing
4 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { buildLocalizedSubQuery } from "./query-utils"; | ||
|
||
describe("buildLocalizedSubQuery", () => { | ||
it("should build a subquery with the given locale", () => { | ||
const subQuery = buildLocalizedSubQuery("s", "p", "o", { | ||
locale: "it", | ||
}); | ||
expect(subQuery).toEqual( | ||
// it locale must be first! | ||
`OPTIONAL { | ||
?s p ?o_it . | ||
FILTER(LANG(?o_it) = "it") | ||
} | ||
OPTIONAL { | ||
?s p ?o_de . | ||
FILTER(LANG(?o_de) = "de") | ||
} | ||
OPTIONAL { | ||
?s p ?o_fr . | ||
FILTER(LANG(?o_fr) = "fr") | ||
} | ||
OPTIONAL { | ||
?s p ?o_en . | ||
FILTER(LANG(?o_en) = "en") | ||
} | ||
OPTIONAL { | ||
?s p ?o_ . | ||
FILTER(LANG(?o_) = "") | ||
} | ||
BIND(COALESCE(?o_it, ?o_de, ?o_fr, ?o_en, ?o_) AS ?o)` | ||
); | ||
}); | ||
|
||
it("should build a subquery with the given locale, falling back to non-localized property", () => { | ||
const subQuery = buildLocalizedSubQuery("s", "p", "o", { | ||
locale: "en", | ||
fallbackToNonLocalized: true, | ||
}); | ||
expect(subQuery).toEqual( | ||
// en locale must be first! | ||
`OPTIONAL { | ||
?s p ?o_en . | ||
FILTER(LANG(?o_en) = "en") | ||
} | ||
OPTIONAL { | ||
?s p ?o_de . | ||
FILTER(LANG(?o_de) = "de") | ||
} | ||
OPTIONAL { | ||
?s p ?o_fr . | ||
FILTER(LANG(?o_fr) = "fr") | ||
} | ||
OPTIONAL { | ||
?s p ?o_it . | ||
FILTER(LANG(?o_it) = "it") | ||
} | ||
OPTIONAL { | ||
?s p ?o_ . | ||
FILTER(LANG(?o_) = "") | ||
} | ||
OPTIONAL { | ||
?s p ?o_raw . | ||
} | ||
BIND(COALESCE(?o_en, ?o_de, ?o_fr, ?o_it, ?o_, ?o_raw) AS ?o)` | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
484475f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
visualization-tool – ./
visualization-tool-ixt1.vercel.app
visualization-tool-alpha.vercel.app
visualization-tool-git-main-ixt1.vercel.app