Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Islands example #246

Merged
merged 20 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
cd end2end
wasm-pack test --headless --${{ matrix.browser }}

build-example:
build-examples:
needs: check-toolchain-is-stable
name: Build example
runs-on: ${{ matrix.runs-on }}
Expand All @@ -226,6 +226,7 @@ jobs:
- csr-complete
- ssr-hydrate-actix
- ssr-hydrate-axum
- ssr-islands-axum
- system-gtk
toolchain:
- stable
Expand Down Expand Up @@ -305,12 +306,9 @@ jobs:
- qa
- unit-tests
- end2end-tests
- build-example
- build-examples
- build-book
if: |
'${{ github.event.pull_request.user.login }}' == 'mondeja' ||
startsWith(github.ref, 'refs/tags/') ||
github.ref == 'refs/heads/master'
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master'
name: Test leptos-fluent-macros release
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ repos:
[
"--features=ssr,actix",
--exclude=leptos-fluent-ssr-hydrate-axum-example,
--exclude=leptos-fluent-ssr-islands-axum-example,
--exclude=leptos-fluent-csr-complete-example,
--exclude=leptos-fluent-csr-minimal-example,
--workspace,
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## [Unreleased]

### Enhancements

- Add `translations` field to `I18n`'s `Debug` implementation.

## 2024-09-25 - [0.1.23]

### Enhancements
Expand Down Expand Up @@ -523,6 +529,7 @@ version to `0.1` during installation.

- Added all ISO-639-1 and ISO-639-2 languages.

[Unreleased]: https://github.com/mondeja/leptos-fluent/compare/v0.1.23...master
[0.1.23]: https://github.com/mondeja/leptos-fluent/compare/v0.1.22...v0.1.23
[0.1.22]: https://github.com/mondeja/leptos-fluent/compare/v0.1.21...v0.1.22
[0.1.21]: https://github.com/mondeja/leptos-fluent/compare/v0.1.20...v0.1.21
Expand Down
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"examples/csr-minimal",
"examples/ssr-hydrate-actix",
"examples/ssr-hydrate-axum",
"examples/ssr-islands-axum",
"examples/system-gtk",
]
resolver = "2"
Expand All @@ -17,13 +18,7 @@ edition = "2021"
documentation = "https://docs.rs/leptos-fluent"
repository = "https://github.com/mondeja/leptos-fluent"
homepage = "https://mondeja.github.io/leptos-fluent"
keywords = [
"leptos",
"fluent",
"i18n",
"localization",
"wasm",
]
keywords = ["leptos", "fluent", "i18n", "localization", "wasm"]

[profile.wasm-release]
inherits = "release"
Expand Down
13 changes: 13 additions & 0 deletions examples/ssr-islands-axum/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by Cargo
# will have compiled files and executables
/target/
pkg

# These are backup files generated by rustfmt
**/*.rs.bk

# node e2e test tools and outputs
node_modules/
test-results/
end2end/playwright-report/
playwright/.cache/
116 changes: 116 additions & 0 deletions examples/ssr-islands-axum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
[package]
name = "leptos-fluent-ssr-islands-axum-example"
version = "0.1.0"
edition = "2021"
publish = false

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
axum = { version = "0.7", optional = true }
console_error_panic_hook = "0.1"
leptos = { version = "0.6", features = ["experimental-islands"] }
leptos_axum = { version = "0.6", optional = true, features = [
"experimental-islands",
] }
leptos_meta = { version = "0.6" }
leptos_router = { version = "0.6" }
tokio = { version = "1", features = ["rt-multi-thread"], optional = true }
tower = { version = "0.4", optional = true, features = ["util"] }
tower-http = { version = "0.5", features = ["fs"], optional = true }
wasm-bindgen = "=0.2.93"
thiserror = "1"
http = "1"

leptos-fluent = { path = "../../leptos-fluent" }
fluent-templates = { version = "0.10", default-features = false, features = [
"macros",
"walkdir",
] }

[features]
hydrate = [
"leptos/hydrate",
"leptos_meta/hydrate",
"leptos_router/hydrate",
"leptos-fluent/hydrate",
]
ssr = [
"dep:axum",
"dep:tokio",
"dep:tower",
"dep:tower-http",
"dep:leptos_axum",
"leptos/ssr",
"leptos_meta/ssr",
"leptos_router/ssr",
"leptos-fluent/ssr",
"leptos-fluent/axum",
]

[package.metadata.leptos]
# Additional files your application could depends on.
# A change to any file in those directories will trigger a rebuild.
watch-additional-files = ["examples/ssr-hydrate-axum/locales"]

# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
output-name = "leptos-fluent-ssr-hydrate-axum-islands-example"

# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
site-root = "target/site"

# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg
site-pkg-dir = "pkg"

# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
style-file = "style/main.css"
# Assets source dir. All files found here will be copied and synchronized to site-root.
# The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir.
#
# Optional. Env: LEPTOS_ASSETS_DIR.
assets-dir = "public"

# The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup.
site-addr = "127.0.0.1:3000"

# The port to use for automatic reload monitoring
reload-port = 3001

# [Optional] Command to use when running end2end tests. It will run in the end2end dir.
# [Windows] for non-WSL use "npx.cmd playwright test"
# This binary name can be checked in Powershell with Get-Command npx
end2end-cmd = "npx playwright test"
end2end-dir = "end2end"

# The browserlist query used for optimizing the CSS.
browserquery = "defaults"

# The environment Leptos will run in, usually either "DEV" or "PROD"
env = "DEV"

# The features to use when compiling the bin target
#
# Optional. Can be over-ridden with the command line parameter --bin-features
bin-features = ["ssr"]

# If the --no-default-features flag should be used when compiling the bin target
#
# Optional. Defaults to false.
bin-default-features = false

# The features to use when compiling the lib target
#
# Optional. Can be over-ridden with the command line parameter --lib-features
lib-features = ["hydrate"]

# If the --no-default-features flag should be used when compiling the lib target
#
# Optional. Defaults to false.
lib-default-features = false

# The profile to use for the lib target when compiling for release
#
# Optional. Defaults to "release".
lib-profile-release = "wasm-release"
24 changes: 24 additions & 0 deletions examples/ssr-islands-axum/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org>
5 changes: 5 additions & 0 deletions examples/ssr-islands-axum/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SSR example with Axum using islands for leptos-fluent

```sh
cargo leptos watch
```
1 change: 1 addition & 0 deletions examples/ssr-islands-axum/locales/header/en/main.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select-language = Select a language
1 change: 1 addition & 0 deletions examples/ssr-islands-axum/locales/header/es/main.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select-language = Selecciona un idioma
1 change: 1 addition & 0 deletions examples/ssr-islands-axum/locales/home/en/main.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
click-me = Click me
1 change: 1 addition & 0 deletions examples/ssr-islands-axum/locales/home/es/main.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
click-me = Haz click
10 changes: 10 additions & 0 deletions examples/ssr-islands-axum/locales/languages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
[
"en",
"EN"
],
[
"es",
"ES"
]
]
5 changes: 5 additions & 0 deletions examples/ssr-islands-axum/locales/server/en/main.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
welcome-to-leptos = Welcome to Leptos
home = Home
home-title = Welcome to the home page
page-2 = Page 2
page-2-title = Welcome to page 2
5 changes: 5 additions & 0 deletions examples/ssr-islands-axum/locales/server/es/main.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
welcome-to-leptos = Bienvenido a Leptos
home = Inicio
home-title = Bienvenido a la página de inicio
page-2 = Página 2
page-2-title = Bienvenido a la página 2
Binary file added examples/ssr-islands-axum/public/favicon.ico
Binary file not shown.
Loading
Loading