Skip to content

Commit ac41a43

Browse files
authored
Merge pull request #33 from skohub-io/32-skohub-vocabs-without-apache-post
32 skohub vocabs without apache post
2 parents 77a2fe8 + d2a6927 commit ac41a43

File tree

1 file changed

+72
-0
lines changed
  • content/blog/2024-01-24-uris-without-language-tags

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: Re-working SkoHub Vocabs internationalization featues
3+
date: "2024-01-31"
4+
authors: [{lastname: "Rörtgen",
5+
firstname: "Steffen",
6+
id: "https://lobid.org/team/sr#"}]
7+
---
8+
9+
## In the past: Internationalization with drawbacks
10+
11+
If you have worked with SkoHub Vocabs before, you might have noticed that the URLs in the address bar had a little special feature that you don't encounter very often, a language tag before the `.html`:
12+
13+
`https://skohub.io/dini-ag-kim/hochschulfaechersystematik/heads/master/w3id.org/kim/hochschulfaechersystematik/scheme.de.html`
14+
15+
Why did we need this?
16+
17+
We wanted Internationalization features to be able to navigate multiple languages.
18+
Normally this is done via a subdomain or adding a language tag behind the domain name like `https://w3id.org/kim/hochschulfaechersystematik/en/`.
19+
But this does not work for SkoHub Vocabs since the we use the URIs from the turtle files as IDs for the concept.
20+
Changing the URI by adding a language tag somewhere would break the whole concept of SkoHub Vocabs.
21+
22+
So it was decided to add the language at the end of the URL by using Apache Multiviews features.
23+
But this lead to some drawbacks:
24+
25+
- SkoHub Vocabs needed to be served by an Apache Webserver
26+
- The webserver needed special configuration
27+
- [SkoHub Docker Vocabs](https://github.com/skohub-io/skohub-docker-vocabs), which is served via GitHub Pages, always needed a specific link to an index.{language}.html file, since GitHub Pages only looks for an `index.html`
28+
- The build directory grew quite a bit, since there were dedicated html pages built for every language
29+
30+
## Switching to one page for all languages
31+
32+
In order to overcome these issues we decided to change this behaviour and just build one html page with a functionality to switch languages. The shown language is now chosen the following way:
33+
34+
- by using your browser language
35+
- if you switched languages in the application the chosen language is taken
36+
- if a language is not present, a default language present in the vocabulary is used
37+
38+
To point users to a specific language, you can use a query parameter `lang=` like:
39+
40+
`https://w3id.org/kim/hcrt/scheme?lang=uk`
41+
42+
Since SkoHub Vocabs also used the language tag of the URL internally to determine which language to serve a lot of changes had to be done in the codebase.
43+
But overall this resulted in a much reduced size of the built vocabularies and more flexibility on serving the vocabularies.
44+
45+
## Benefits of the new approach
46+
47+
This new internationalization approach brings lots of improvements:
48+
49+
- SkoHub Vocabs is now independent from the underlying webserver
50+
- The size of the vocabularies is drastically reduced, especially for vocabularies with lots of languages
51+
- [SkoHub Docker Vocabs](https://github.com/skohub-io/skohub-docker-vocabs) is now simpler to setup since we only have "normal" `index.html` files that it knows how to handle
52+
53+
## What to do if I'm running my own webhook server?
54+
55+
If you are running your own webhook server, you should upgrade the following way:
56+
57+
- Follow the steps outlined in the webhook repository to [rebuild vocabularies](https://github.com/skohub-io/skohub-webhook#rebuilding-vocabularies). This will rebuild all still existing branches you are currently serving.
58+
- Set up a redirect in your apache config, so that links that still have `...de.html` will be redirected to `...html?lang=de`:
59+
```
60+
# Redirect from ...filename.LANGCODE.html to ...filename.html?lang=LANGCODE
61+
RewriteRule ^(.+)\.([a-z]{2})\.html$ $1.html?lang=$2 [L,R=301]
62+
```
63+
- After that you should be good!
64+
65+
## Anything else?
66+
67+
During developing the script to rebuild all existing vocabularies, I noticed that we are serving a lot of branches that do not exist anymore.
68+
SkoHub Webhook currently builds a vocabulary for every branch, you are setting up and pushing to.
69+
But the webhook service does not get notified, when a branch is deleted.
70+
This way we end up having lots of files for branches that no one needs anymore.
71+
In order to clean this up a bit, we will soon add a script to clean the dist directory up and remove those no longer needed files.
72+

0 commit comments

Comments
 (0)