@@ -36,16 +36,29 @@ macro_rules! define_get_translations_manager {
36
36
. await
37
37
}
38
38
} ;
39
+ ( $locales: expr, $no_i18n: literal) => {
40
+ pub async fn get_translations_manager( ) -> impl $crate:: TranslationsManager {
41
+ $crate:: translations_manager:: DummyTranslationsManager :: new( )
42
+ }
43
+ } ;
39
44
( $locales: expr, $translations_manager: expr) => {
40
- pub fn get_translations_manager( ) -> impl $crate:: TranslationsManager {
45
+ pub async fn get_translations_manager( ) -> impl $crate:: TranslationsManager {
46
+ $translations_manager
47
+ }
48
+ } ;
49
+ // If the user doesn't want i18n but also sets their own transations manager, the latter takes priority
50
+ ( $locales: expr, $no_i18n: literal, $translations_manager: expr) => {
51
+ pub async fn get_translations_manager( ) -> impl $crate:: TranslationsManager {
41
52
$translations_manager
42
53
}
43
54
} ;
44
55
}
45
56
46
57
/// Defines the components to create an entrypoint for the app. The actual entrypoint is created in the `.perseus/` crate (where we can
47
58
/// get all the dependencies without driving the user's `Cargo.toml` nuts). This also defines the template map. This is intended to make
48
- /// compatibility with the Perseus CLI significantly easier.
59
+ /// compatibility with the Perseus CLI significantly easier. Perseus makes i18n opt-out, so if you don't intend to use it, set `no_i18n`
60
+ /// to `true` in `locales`. Note that you must still specify a default locale for verbosity and correctness. If you specify `no_i18n` and
61
+ /// a custom translations manager, the latter will override.
49
62
#[ macro_export]
50
63
macro_rules! define_app {
51
64
{
@@ -71,6 +84,7 @@ macro_rules! define_app {
71
84
default : $default_locale: literal,
72
85
// The user doesn't have to define any other locales
73
86
other: [ $( $other_locale: literal) ,* ]
87
+ $( , no_i18n: $no_i18n: literal) ?
74
88
}
75
89
$( , config_manager: $config_manager: expr) ?
76
90
$( , translations_manager: $translations_manager: expr) ?
@@ -87,7 +101,7 @@ macro_rules! define_app {
87
101
88
102
/// Gets the translations manager to use. This allows the user to conveniently test production managers in development. If
89
103
/// nothing is given, the filesystem will be used.
90
- $crate:: define_get_translations_manager!( get_locales( ) $( , $translations_manager) ?) ;
104
+ $crate:: define_get_translations_manager!( get_locales( ) $( , $no_i18n ) ? $ ( , $ translations_manager) ?) ;
91
105
92
106
/// Defines the locales the app should build for, specifying defaults and common locales (which will be built at build-time
93
107
/// rather than on-demand).
0 commit comments