Skip to content

Commit

Permalink
Update Qwik to 0.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
robisim74 committed Feb 23, 2023
1 parent f1eb895 commit ff04f5a
Show file tree
Hide file tree
Showing 19 changed files with 480 additions and 577 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module.exports = {
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'@typescript-eslint/consistent-type-imports': 'warn',
'prefer-spread': 'off',
'no-case-declarations': 'off',
'no-console': 'off',
Expand Down
12 changes: 5 additions & 7 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _src/speak-config.ts_
```typescript
import { $ } from '@builder.io/qwik';
import { isServer } from '@builder.io/qwik/build';
import {
import type {
LoadTranslationFn,
SpeakConfig,
TranslationFn
Expand Down Expand Up @@ -211,11 +211,6 @@ export default component$(() => {
```
`changeLocale` function by Qwik Speak is responsible for the language change, and it falls back to the default locale if the new locale is not in `supportedLocales`.

## Running
You can already try the app: `npm start`

You will notice that in the translations there are default values for both languages.

## Extraction: [Qwik Speak Extract](../tools/extract.md)
We can now extract the translations and generate the `assets` as json. In `package.json` add the following command to the scripts:
```json
Expand All @@ -235,7 +230,10 @@ public/i18n/it-IT/home.json
```
`app` asset and `home` asset for each language, initialized with the default values we provided.

We can translate the `it-IT` files, and run the app again.
We can translate the `it-IT` files, and run the app.

## Running
You can try the app: `npm start`

## Inlining: [Qwik Speak Inline Vite plugin](../tools/inline.md)
Let's make sure that translation files are loaded only in dev mode. Update the `loadTranslation$` function:
Expand Down
2 changes: 1 addition & 1 deletion docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test(`[Home Component]: Should render translated texts`, async () => {

Optionally, if you need to test the translated texts in different languages, you have to provide a stub `loadTranslation$` to ensure translations are loaded in test environment. For example you could load the json files of translations as follows:
```typescript
const loadTranslationStub$: LoadTranslationFn = $((lang: string, asset: string, origin?: string) =>
const loadTranslationStub$: LoadTranslationFn = $((lang: string, asset: string) =>
JSON.parse(
import.meta.glob('/public/i18n/**/*.json', { as: 'raw', eager: true })[
`/public/i18n/${lang}/${asset}.json`
Expand Down
12 changes: 6 additions & 6 deletions docs/tutorial-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,6 @@ In `localizeUrl$` we replace the language in the URL, using the Qwik City naviga

> As an alternative you could avoid calling `changeLocale`, you could just navigate directly to the new localized URL. This may be necessary in production if you have different domains for each location.
## Running
You can already try the app: `npm start`

You will notice that in the translations there are default values for both languages, and that when you change language the URL updates.

## Extraction: [Qwik Speak Extract](../tools/extract.md)
We can now extract the translations and generate the `assets` as json. In `package.json` add the following command to the scripts:
```json
Expand Down Expand Up @@ -300,7 +295,12 @@ _public/i18n/[lang]/runtime.json_
```
> Don't forget to update the keys in `DocumentHead` of `index.tsx` and add `runtime` asset in Speak config.
We can translate the `it-IT` files, and run the app again.
We can translate the `it-IT` files, and run the app.

## Running
You can try the app: `npm start`

You will notice that when you change language the URL updates.

## Inlining: [Qwik Speak Inline Vite plugin](../tools/inline.md)
Let's make sure that the `runtime` file is loaded and others only in dev mode. Update the `loadTranslation$` function:
Expand Down
Loading

0 comments on commit ff04f5a

Please sign in to comment.