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

Remove deprecated component SsrHtmlTag #226

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# CHANGELOG

## Unreleased - 0.2.0

### Breaking changes

- The `leptos_fluent!` macro now uses single curly braces:

```diff
- leptos_fluent! {{
+ leptos_fluent! {
// ...
- }}
+ }
```

- The deprecated component `SsrHtmlTag` has been removed as is not needed
anymore.

## 2024-08-17 - [0.1.17]

### New features
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr-hydrate-axum/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use fluent_templates::static_loader;
use fluent_templates::StaticLoader;
use leptos::*;
use leptos_fluent::{expect_i18n, leptos_fluent, move_tr, tr};
use leptos_meta::*;
use leptos_meta::Title;
use leptos_router::*;

static_loader! {
Expand Down
14 changes: 7 additions & 7 deletions leptos-fluent-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![deny(missing_docs)]
#![forbid(unsafe_code)]
#![cfg_attr(feature = "nightly", feature(track_path))]
#![cfg_attr(feature = "nightly", feature(absolute_path))]

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (csr-minimal, nightly, ubuntu-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (csr-minimal, nightly, macos-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (csr-complete, nightly, ubuntu-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (csr-complete, nightly, macos-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (ssr-hydrate-actix, nightly, ubuntu-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (ssr-hydrate-actix, nightly, ubuntu-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (ssr-hydrate-actix, nightly, macos-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (ssr-hydrate-actix, nightly, macos-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (ssr-hydrate-axum, nightly, ubuntu-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (ssr-hydrate-axum, nightly, ubuntu-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (ssr-hydrate-axum, nightly, macos-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (ssr-hydrate-axum, nightly, macos-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (system-gtk, nightly, ubuntu-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

Check warning on line 4 in leptos-fluent-macros/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build example (system-gtk, nightly, macos-latest)

the feature `absolute_path` has been stable since 1.79.0 and no longer requires an attribute to enable

//! Macros for the leptos-fluent crate.
//!
Expand Down Expand Up @@ -255,7 +255,7 @@
};

let effect_quote = quote! {
if let Ok(l) = ::leptos_fluent::current_locale() {
if let Ok(l) = ::leptos_fluent::current_locale::current_locale() {
lang = ::leptos_fluent::l(&l, &LANGUAGES);
if let Some(l) = lang {
#initial_language_from_system_to_data_file_quote
Expand Down Expand Up @@ -737,8 +737,8 @@
// Calling `provide_meta_context()` to not show a warning
#[cfg(feature = "ssr")]
let previous_html_tag_attrs_quote = quote! {{
::leptos_meta::provide_meta_context();
let html_tag_as_string = ::leptos_meta::use_head().html.as_string().unwrap_or("".to_string());
::leptos_fluent::leptos_meta::provide_meta_context();
let html_tag_as_string = ::leptos_fluent::leptos_meta::use_head().html.as_string().unwrap_or("".to_string());
let mut class: Option<::leptos::TextProp> = None;
let mut lang: Option<::leptos::TextProp> = None;
let mut dir: Option<::leptos::TextProp> = None;
Expand Down Expand Up @@ -791,8 +791,8 @@
quote! {
let l = #get_language_quote;
let (class, _, dir) = #previous_html_tag_attrs_quote;
::leptos_meta::Html(
::leptos_meta::HtmlProps {
::leptos_fluent::leptos_meta::Html(
::leptos_fluent::leptos_meta::HtmlProps {
lang: Some(l.id.to_string().into()),
dir: if #sync_html_tag_dir_bool_quote {
Some(l.dir.as_str().into())
Expand Down Expand Up @@ -856,8 +856,8 @@
quote! {
let l = #get_language_quote;
let (class, lang, _) = #previous_html_tag_attrs_quote;
::leptos_meta::Html(
::leptos_meta::HtmlProps {
::leptos_fluent::leptos_meta::Html(
::leptos_fluent::leptos_meta::HtmlProps {
lang: if #sync_html_tag_lang_bool_quote {
Some(l.id.to_string().into())
} else {
Expand Down
67 changes: 8 additions & 59 deletions leptos-fluent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,14 @@ pub mod localstorage;
#[doc(hidden)]
pub mod url;

#[doc(hidden)]
#[cfg(feature = "system")]
pub use current_locale::current_locale;
pub extern crate current_locale;
#[cfg(feature = "ssr")]
#[doc(hidden)]
pub extern crate leptos_meta;
#[doc(hidden)]
pub use web_sys;
pub extern crate web_sys;

use core::hash::{Hash, Hasher};
use core::str::FromStr;
Expand All @@ -285,14 +289,10 @@ use fluent_templates::{
LanguageIdentifier, StaticLoader,
};
use leptos::{
component, use_context, with, Attribute, IntoAttribute, IntoView, Oco,
RwSignal, Signal, SignalGet, SignalSet,
use_context, with, Attribute, IntoAttribute, Oco, RwSignal, Signal,
SignalGet, SignalSet,
};
#[cfg(feature = "ssr")]
use leptos::{view, SignalGetUntracked};
pub use leptos_fluent_macros::leptos_fluent;
#[cfg(feature = "ssr")]
use leptos_meta::Html;
use std::rc::Rc;

/// Direction of the text
Expand Down Expand Up @@ -797,57 +797,6 @@ pub fn l(
language_from_str_between_languages(code, languages)
}

/// Reactive HTML tag to set attributes on SSR
///
/// Currently there is not a way to set the `dir` and `lang` attributes
/// of `<html>` tags on SSR. This components updates it on SSR. Must be
/// rendered in a view.
///
/// ```rust,ignore
/// use leptos_fluent::SsrHtmlTag;
///
/// view! {
/// <SsrHtmlTag/>
/// }
/// ```
#[deprecated(
since = "0.1.14",
note = "The component SsrHtmlTag is not needed anymore and will be removed in v0.2. \
The `sync_html_tag_lang` and `sync_html_tag_dir` parameters of the `leptos_fluent!` \
macro are enough to set the `lang` and `dir` attributes of the `<html>` tag on SSR."
)]
#[component(transparent)]
#[cfg(feature = "ssr")]
#[cfg_attr(feature = "tracing", tracing::instrument(level = "trace"))]
pub fn SsrHtmlTag() -> impl IntoView {
let lang = expect_i18n().language.get_untracked();
view! { <Html lang=lang.id.to_string() dir=lang.dir.as_str()/> }
}

/// Reactive HTML tag to set attributes on SSR
///
/// Currently there is not a way to set the `dir` and `lang` attributes
/// of `<html>` tags on SSR. This components updates it on SSR. Must be
/// rendered in a view.
///
/// ```rust,ignore
/// use leptos_fluent::SsrHtmlTag;
///
/// view! {
/// <SsrHtmlTag/>
/// }
/// ```
#[deprecated(
since = "0.1.14",
note = "The component `SsrHtmlTag` is not needed anymore and will be removed in v0.2. \
The `sync_html_tag_lang` and `sync_html_tag_dir` parameters of the `leptos_fluent!` \
macro are enough to set the `lang` and `dir` attributes of the `<html>` tag on SSR."
)]
#[component(transparent)]
#[cfg(not(feature = "ssr"))]
#[cfg_attr(feature = "tracing", tracing::instrument(level = "trace"))]
pub fn SsrHtmlTag() -> impl IntoView {}

/// Parameters passed to `leptos_fluent!` macro at creation of `i18n` context
#[derive(Clone, Debug)]
#[doc(hidden)]
Expand Down