Replies: 5 comments 1 reply
-
We're using Framework to document Framework, and my absolutely unbiased opinion is that it's a very nice experience. There's admittedly not much yet in the area of plurilinguism—it can only improve (using lang, dir, connecting translations, etc.). I think however that this type of use case —like blogging (#1199)— will have to be chiefly driven and developed by the user community. (You're welcome to use this discussion board to share your experiments and define what might be needed to make progress.) |
Beta Was this translation helpful? Give feedback.
-
This sounds like a fun and exciting challenge. I'll test a few things. :) |
Beta Was this translation helpful? Give feedback.
-
A quick first test for French and English, just by playing with the You can see it here: https://github.com/nshiab/framework Here are the steps I took:
![]()
![]()
pages: [
// ENGLISH
{name: "Hi!", path: "/en/index"},
{
name: "Examples",
pages: [
{name: "Example 1", path: "/en/example-1"},
{name: "Example 2", path: "/en/example-2"},
{name: "Example 3", path: "/en/example-3"}
]
},
// FRENCH
{name: "Coucou!", path: "/fr/index"},
{
name: "Exemples",
pages: [
{name: "Exemple 1", path: "/fr/example-1"},
{name: "Exemple 2", path: "/fr/example-2"},
{name: "Exemple 3", path: "/fr/example-3"}
]
}
]
header: `
<div style="display: flex; flex-grow: 1; align-items: center; justify-content: space-between; white-space: nowrap;">
...
<span style="display: flex; align-items: baseline; gap: 1rem;">
...
<select id="select-language">
<option>en</option>
<option>fr</option>
</select>
</span>
</div>
footer: ({path}) =>
`<div>© ${new Date().getUTCFullYear()} Observable, Inc.</div>
<script>
// Retrieve the current language from the path
const lang = "${path.split("/")[1]}"
// Set the language select to the current language
const selectLanguage = document.getElementById("select-language");
selectLanguage.value = lang;
// If the user selects a new language, we modify the path and redirect
selectLanguage.addEventListener("change", (event) => {
window.location.href = "/" + event.target.value + "/" + "${path.split("/").slice(2).join("/")}"
});
// Retrieve all languages from the select, except the current one
const allLangs = Array.from(selectLanguage.options).map(option => option.value).filter(d => d !== lang);
// Remove links from the sidebar that are not pointing to the current language
for (const l of allLangs) {
document.querySelectorAll('#observablehq-sidebar ol .observablehq-link').forEach(link => {
if (link.querySelector("a").getAttribute('href').includes('/' + l + '/')) {
link.remove();
}
});
}
// We remove empty sections
document.querySelectorAll('section').forEach(section => {
if (!section.querySelector('ol') || !section.querySelector('ol').children.length) {
section.remove();
}
});
</script>`
Pros:
Cons:
What do you think @Fil ? |
Beta Was this translation helpful? Give feedback.
-
Ah! Very nice. I updated pages: [
// ENGLISH
{name: "Hi!", path: "/en/index", pager: "en"},
{
name: "Examples",
pager: "en",
pages: [
{name: "Example 1", path: "/en/example-1"},
{name: "Example 2", path: "/en/example-2"},
{name: "Example 3", path: "/en/example-3"}
]
},
// FRENCH
{name: "Coucou!", path: "/fr/index", pager: "fr"},
{
name: "Exemples",
pager: "fr",
pages: [
{name: "Exemple 1", path: "/fr/example-1"},
{name: "Exemple 2", path: "/fr/example-2"},
{name: "Exemple 3", path: "/fr/example-3"}
]
}
], Do you think If it could be specified as a function receiving the Would it be difficult to do? |
Beta Was this translation helpful? Give feedback.
-
I think I managed to do it! See here: nshiab@5c5603f I changed I changed I changed And it looks like it works! What do you think @Fil ? Should I create a PR? |
Beta Was this translation helpful? Give feedback.
-
The more I use Framework for my data analysis work, the more I feel it would be an excellent fit for documentation, too.
But is there any easy way to display/organize content in multiple languages?
Just an idea! :)
Beta Was this translation helpful? Give feedback.
All reactions