Skip to content

Commit 484ca40

Browse files
committed
Extend documentation with getLocaleFromAcceptLanguageHeader
1 parent 24f1201 commit 484ca40

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules
44
/build
55
/.svelte-kit
66
/package
7+
/.idea

locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
"configuration.definitions.hash": "Like <pre class='inline'>getLocaleFromQueryString</pre> but for the URL hash.<br>E.g <pre class='inline'>getLocaleFromHash('lang')</pre> for <pre class='inline'>/users#sort=name&amp;dir=asc&amp;lang=es</pre>",
141141
"configuration.definitions.path": "Extracts the locale from the path of the URL.<br>E.g <pre class='inline'>getLocaleFromPathname(/^\/((es|en)(-\\w\\w)?)/)</pre> for <pre class='inline'>myapp.com/en-US/users</pre>",
142142
"configuration.definitions.host": "Extracts the locale from host.<br>E.g <pre class='inline'>getLocaleFromHostname(/^((es|en)(-\\w\\w)?)\\./)</pre> for <pre class='inline'>https://pt.myapp.com</pre>",
143+
"configuration.definitions.acceptLanguage": "Extracts the locale from the Accept-Language header based on a list of available locales. If availableLocales is omitted, returns the first language from the header.<br>E.g. <pre class='inline'>getLocaleFromAcceptLanguageHeader('en-GB,en;q=0.9,es-ES;q=0.8,en-US;q=0.6', ['fr', 'es', 'de'])</pre> for <pre class='inline'>'es'</pre>",
143144
"configuration.subsection.custom-formats": "Custom formats",
144145
"configuration.paragraph.custom-formats-1": "This library can format numbers, dates and times. It does it without adding significant weight to your app by leveraging the Intl API already present in all modern browsers and in Node.js.<br/>By default you app can use these formats, but you can add your own.",
145146
"configuration.paragraph.custom-formats-2": "If you want to define your own formats pass them on initialization using the",

src/routes/[...lang]/docs/configuration.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ addMessages('es', es);
148148
<svelte:fragment slot="dt"><pre>getLocaleFromHostname(regex)</svelte:fragment>
149149
<svelte:fragment slot="dd">{@html $t('configuration.definitions.host')}</svelte:fragment>
150150
</DefinitionEntry>
151+
<DefinitionEntry background="gray">
152+
<svelte:fragment slot="dt"><pre>getLocaleFromAcceptLanguageHeader(header, availableLocales?)</pre></svelte:fragment>
153+
<svelte:fragment slot="dd">{@html $t('configuration.definitions.acceptLanguage')}</svelte:fragment>
154+
</DefinitionEntry>
151155
</dl>
152156

153157
<h2 class="text-xl font-semibold" id="custom-formats">{$t('configuration.subsection.custom-formats')}</h2>

0 commit comments

Comments
 (0)