diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4cf6348..a0613fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -96,6 +96,9 @@ importers: html-minifier: specifier: ^4.0.0 version: 4.0.0 + mdsvex: + specifier: ^0.11.0 + version: 0.11.0(svelte@3.59.2) postcss: specifier: ^8.4.31 version: 8.4.31 @@ -635,6 +638,10 @@ packages: resolution: {integrity: sha512-QzhsZ1dMGyJbn/D9V80zp4GIA4J4rfAjCCxc3MP+new0E8dyVdSkR735Lx+n3LIaHNFcjHL5+TbziccuT+fdoQ==} dev: true + /@types/unist@2.0.9: + resolution: {integrity: sha512-zC0iXxAv1C1ERURduJueYzkzZ2zaGyc+P2c95hgkikHPr3z8EdUZOlgEQ5X0DRmwDZn+hekycQnoeiiRVrmilQ==} + dev: true + /@vitest/expect@0.34.6: resolution: {integrity: sha512-QUzKpUQRc1qC7qdGo7rMK3AkETI7w18gTCUrsNnyjjJKYiuUB9+TQK3QnR1unhCnWRC0AbKv2omLGQDF/mIjOw==} dependencies: @@ -1337,6 +1344,18 @@ packages: resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==} dev: false + /mdsvex@0.11.0(svelte@3.59.2): + resolution: {integrity: sha512-gJF1s0N2nCmdxcKn8HDn0LKrN8poStqAicp6bBcsKFd/zkUBGLP5e7vnxu+g0pjBbDFOscUyI1mtHz+YK2TCDw==} + peerDependencies: + svelte: '>=3 <5' + dependencies: + '@types/unist': 2.0.9 + prism-svelte: 0.4.7 + prismjs: 1.29.0 + svelte: 3.59.2 + vfile-message: 2.0.4 + dev: true + /merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} dev: true @@ -1664,10 +1683,13 @@ packages: react-is: 18.2.0 dev: true + /prism-svelte@0.4.7: + resolution: {integrity: sha512-yABh19CYbM24V7aS7TuPYRNMqthxwbvx6FF/Rw920YbyBWO3tnyPIqRMgHuSVsLmuHkkBS1Akyof463FVdkeDQ==} + dev: true + /prismjs@1.29.0: resolution: {integrity: sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==} engines: {node: '>=6'} - dev: false /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} @@ -2095,6 +2117,12 @@ packages: '@fastify/busboy': 2.0.0 dev: true + /unist-util-stringify-position@2.0.3: + resolution: {integrity: sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==} + dependencies: + '@types/unist': 2.0.9 + dev: true + /unplugin-icons@0.17.1: resolution: {integrity: sha512-KsWejBPCHokYCNDQUzGu6R3E3XDYH/YpewgQwrVBXgpl1iR0RdW1NEGNdjlbuapwVnZXVgA5eiDTfNaQCawSdg==} peerDependencies: @@ -2154,6 +2182,13 @@ packages: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} dev: true + /vfile-message@2.0.4: + resolution: {integrity: sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==} + dependencies: + '@types/unist': 2.0.9 + unist-util-stringify-position: 2.0.3 + dev: true + /vite-node@0.34.6(@types/node@20.7.2): resolution: {integrity: sha512-nlBMJ9x6n7/Amaz6F3zJ97EBwR2FkzhBRxF5e+jE6LA3yi6Wtc2lyTij1OnDMIr34v5g/tVQtsVAzhT0jc5ygA==} engines: {node: '>=v14.18.0'} diff --git a/site/package.json b/site/package.json index edf52b9..281f461 100644 --- a/site/package.json +++ b/site/package.json @@ -18,6 +18,7 @@ "@tailwindcss/typography": "^0.5.10", "autoprefixer": "^10.4.16", "html-minifier": "^4.0.0", + "mdsvex": "^0.11.0", "postcss": "^8.4.31", "svelte": "^3.54.0", "svelte-check": "^3.0.1", diff --git a/site/src/lib/ui/Pagination.svelte b/site/src/lib/ui/Pagination.svelte new file mode 100644 index 0000000..291d229 --- /dev/null +++ b/site/src/lib/ui/Pagination.svelte @@ -0,0 +1,25 @@ + + + diff --git a/site/src/routes/[[locale=locale]]/$t18s/+page.svelte b/site/src/routes/[[locale=locale]]/$t18s/+page.svx similarity index 57% rename from site/src/routes/[[locale=locale]]/$t18s/+page.svelte rename to site/src/routes/[[locale=locale]]/$t18s/+page.svx index 0307b2a..9b473fb 100644 --- a/site/src/routes/[[locale=locale]]/$t18s/+page.svelte +++ b/site/src/routes/[[locale=locale]]/$t18s/+page.svx @@ -4,14 +4,13 @@ import locale_param_matcher_snippet from "./locale-param-matcher-snippet.js?raw"; -
- The `$t18s` module contains all runtime code for t18s. It is how you interact - with the library. -
+# $t18s Module Reference -type Locale
A union type of all the locales you have registered with t18s.
+The `$t18s` module contains all runtime code for t18s. It is how you interact +with the library. + +## `type Locale` +A union type of all the locales you have registered with t18s.locales
- An array of all the locales you have registered with t18s. Useful for places - where you need to iterate over all locales, such as Locale Switchers or SEO. -
+## `locales` + +An array of all the locales you have registered with t18s. Useful for places +where you need to iterate over all locales, such as Locale Switchers or SEO. -$locale
StoreA writable store containing the currently active locale.
+## `$locale` Store + +A writable store containing the currently active locale.isLocale
- A convenience function for checking if something is a valid locale or not. - Only the locales that are registered with t18s are considered valid. -
+## `isLocale` + +A convenience function for checking if something is a valid locale or not. +Only the locales that are registered with t18s are considered valid.It is useful for quickly creating a param matcher for locales.
+It is useful for quickly creating a param matcher for locales.setLocale
Sets the current locale. Useful for Locale Switchers.
+## `setLocale` -$t
StorepreloadLocale
- Preloads any messages that are needed for the given locale. Call this before - trying to display any messages to avoid a flash of fallbacks. This is usually - done in `+page.js` files. -
+## `preloadLocale` + +Preloads any messages that are needed for the given locale. Call this before +trying to display any messages to avoid a flash of fallbacks. This is usually +done in `+page.js` files.const fallbackLocale
- The fallback locale you specified in your config, or null if you don't specify one. Will be definitely - typed based on your config. -
+## `const fallbackLocale` + +The fallback locale you specified in your config, or null if you don't specify one. Will be definitely +typed based on your config.- There are quite a few i18n libraries available for Svelte. Here is how - t18s compares to the most popular ones. -
+# Comparisons to other Libraries + +There are quite a few i18n libraries available for Svelte. Here is how +t18s compares to the most popular ones.First you need to install t18s as a dev dependency.
+First you need to install t18s as a dev dependency.- T18S isn't just a library, it's a vite-plugin, so you will need to register it - in your vite config. -
+T18S isn't just a library, it's a vite-plugin, so you will need to register it +in your vite config.- You will need to at least one option in the plugin options; The list of - locales that you want to support. Additionally you may use a fallback locale - that will be used if a message is missing in the current locale. -
+You will need to at least one option in the plugin options; The list of +locales that you want to support. Additionally you may use a fallback locale +that will be used if a message is missing in the current locale. diff --git a/site/src/routes/[[locale=locale]]/plugin-config/+page.svelte b/site/src/routes/[[locale=locale]]/plugin-config/+page.svelte deleted file mode 100644 index 520563e..0000000 --- a/site/src/routes/[[locale=locale]]/plugin-config/+page.svelte +++ /dev/null @@ -1 +0,0 @@ -- T18S is not done. There is still a lot we want to add. Here are some of our - ideas for the future in no particular order. -
- -- T18S is still relatively new, and hasn't handled all the edge cases yet. This causes occasional - problems with the dev-server, reloading translations and other inconveniences. We want to make sure - that t18s is as robust as possible and can deliver the best experience possible. -
- - -- There exists a wide range of file formats for translations. We want to support as many of them as possible - in order to allow developers and translators to use the tools they are most comfortable with. -
- -- SvelteKit currently doesn't offer a built in way to internationalize routes. It's left - to the developer to implement this. We want to provide a standard and straight forward - way to do this. Due to the complexity of the problem there are still a lot of open questions here, - and there is a lot of experimenting left to be done. -
- -- There are a few proof-of-concept tools & sites out there that push the - boundary of how we interact with the things we build. One of those is - better-i18n-for-svelte. It's a proof of concept for editing translations in your dev-browser - directly, instead of files. -
- - - -- We want to experiment with implementing features like this in t18s. There are a lot of open questions - with this though. How do we determine which text came from a translation? How do we handle variable interpolation - in the editor, how do we add new translations? -
- -- Until we have answers to these questions, this will remain relatively low priority. -
diff --git a/site/src/routes/[[locale=locale]]/roadmap/+page.svx b/site/src/routes/[[locale=locale]]/roadmap/+page.svx new file mode 100644 index 0000000..71df6ac --- /dev/null +++ b/site/src/routes/[[locale=locale]]/roadmap/+page.svx @@ -0,0 +1,48 @@ + + +# Roadmap + +T18S is not done. There is still a lot we want to add. Here are some of our +ideas for the future in no particular order. + +## Robustness + +T18S is still relatively new, and hasn't handled all the edge cases yet. This causes occasional +problems with the dev-server, reloading translations and other inconveniences. We want to make sure +that t18s is as robust as possible and can deliver the best experience possible. + +## Support more File Formats + +There exists a wide range of file formats for translations. We want to support as many of them as possible +in order to allow developers and translators to use the tools they are most comfortable with. + +## Built in Internationalized Routing + +SvelteKit currently doesn't offer a built in way to internationalize routes. It's left +to the developer to implement this. We want to provide a standard and straight forward +way to do this. Due to the complexity of the problem there are still a lot of open questions here, +and there is a lot of experimenting left to be done. + +## Interactive Translation + +There are a few proof-of-concept tools & sites out there that push the +boundary of how we interact with the things we build. One of those is +[better-i18n-for-svelte](https://github.com/versiobit/better-i18n-for-svelte). +It's a proof of concept for editing translations in your dev-browser directly, +instead of in files. + + + +We want to experiment with implementing features like this in t18s. There are a lot of open questions +with this though. How do we determine which text came from a translation? How do we handle variable interpolation +in the editor, how do we add new translations? + +Until we have answers to these questions, this will remain relatively low priority. diff --git a/site/src/routes/[[locale=locale]]/seo/+page.svelte b/site/src/routes/[[locale=locale]]/seo/+page.svelte deleted file mode 100644 index 5b5c69f..0000000 --- a/site/src/routes/[[locale=locale]]/seo/+page.svelte +++ /dev/null @@ -1,131 +0,0 @@ - -- There are quite a few SEO related things you need to keep in mind when developing - a multi-language site. This page will give you a quick overview of the most important ones. -
- - -- Alternate links are a way to tell search engines that a page exists in multiple languages, - and where to find them. This is done by adding a link tag to the head of your page. -
- - -- You should add a link tag for each language your site is available in, including the - one the page is currently in. -
- -
- If you have a "default lanugage" that you want to use when the user's language is not available,
- you should add a link tag with the hreflang
attribute set to x-default
. This
- tells search engines that this is the default language.
-
- It is recommended that you use a
tags for your locale switchers. This is because
- search engines and the SvelteKit prerenderer will follow these links, and index the pages they lead to. They
- also work if JavaScript is disabled.
-
- But, we need to make sure to tell the search engines that these links just lead to the same page
- in a different language, not separate pages. We do this by adding an hreflang
attribute.
-
- Browsers determine the page's language by looking at the lang
attribute on the html
tag.
- We need to make sure that this attribute is set to the correct language, both during server rendering,
- and when switching languages on the client.
-
- SvelteKit offers a relatively simple way to set the lang
attribute during server rendering.
- We can set it in a hook.
-
- In the app template, let's add a placeholder string in the lang
attribute.
-
- Then in the server handle
hook, we can replace it with the correct language.
-
- T18S does not do a full page reload when switching languages, so we need to make sure that the lang
attribute
- gets set correctly when switching languages on the client.
-
- In the root layout. Check that we are in the browser,
- and then reactively set the lang
attribute base on the $locale
store exported
- by T18S.
-
- T18s uses the ICU MessageFormat Syntax for messages, the de-facto standard in the JavaScript ecosystem. Let's - learn how to use it. -
- -Hello {"{fullName}"}, how are you?
- You can specify that a value is not a string by adding a type-annotation in
- the curly braces. The known types are number
, date
,
- and time
.
-
Intl
API under the hood.
+locale you are using. It uses the `Intl` API under the hood.
Generally the format for interpolating values is always this.
-- The options that are available vary by type. You can find a list of all the - options for each type in the ICU MessageFormat - documentation. (We do support skeletons) -
+1. Varaible Name +2. Format Type +3. Format Options + +The options that are available vary by type. You can find a list of all the +options for each type in the +[ICU MessageFormat](https://unicode-org.github.io/icu/userguide/format_parse/messages) +documentation. +(We **do** support skeletons) -- You can use pluralization to use different messages based on a number. This is - useful for things like "1 person" vs "2 people". -
+You can use pluralization to use different messages based on a number. This is +useful for things like "1 person" vs "2 people". -- You can declare them by using the `plural` type and listing out the options. -
+You can declare them by using the `plural` type and listing out the options.You can also match an exact number by using an equals sign before it.
+You can also match an exact number by using an equals sign before it.
- You can use the number itself inside the message by using the #
placeholder.
-
- Select allows you to use one of multiple values based on a key. This is useful - for grammatical gender. -
+## Select -
- You use it by using the select
type, and then listing out each option
- with a key and a value in curly braces.
-
- The special key other
is used as a fallback if no other key matches.
-
selectordinal
type.
+to plural, but with the `selectordinal` type.
selectordinal
type.
same ordianl for 1st and 21st.
-- Sometimes you want to dynamically insert HTML into your messages. You can do - this by writing tags inside your messages. However, these tags aren't raw html, - they too are translated. When formatting the message, you will need to pass in - a callback that takes in the text-content of the tag and returns the html you want to insert. -
+## Inline HTML + +Sometimes you want to dynamically insert HTML into your messages. You can do +this by writing tags inside your messages. However, these tags aren't raw html, +they too are translated. When formatting the message, you will need to pass in +a callback that takes in the text-content of the tag and returns the html you want to insert.selectordinal
type.