summaryrefslogtreecommitdiff
path: root/examples/docs/src/components/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'examples/docs/src/components/util.ts')
-rw-r--r--examples/docs/src/components/util.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/examples/docs/src/components/util.ts b/examples/docs/src/components/util.ts
new file mode 100644
index 000000000..0ec91bce0
--- /dev/null
+++ b/examples/docs/src/components/util.ts
@@ -0,0 +1,4 @@
+export function getLanguageFromURL(pathname: string) {
+ const langCodeMatch = pathname.match(/\/([a-z]{2}-?[A-Z]{0,2})\//);
+ return langCodeMatch ? langCodeMatch[1] : 'en';
+}