1
0
forked from baron/baron-sso

userfront i18n placeholder 치환과 번역 렌더링 오류 수정

This commit is contained in:
2026-04-06 17:48:07 +09:00
parent beae6bb4b1
commit d086b7ea3c
4 changed files with 88 additions and 30 deletions

View File

@@ -57,6 +57,18 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
Map<String, dynamic>? _passwordPolicy;
bool _isPasswordPolicyLoading = false;
String _renderTranslatedText(
String key, {
String? fallback,
Map<String, String> values = const {},
}) {
var text = tr(key, fallback: fallback);
values.forEach((name, value) {
text = text.replaceAll('{{$name}}', value).replaceAll('{$name}', value);
});
return text;
}
@override
void initState() {
super.initState();
@@ -98,16 +110,16 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
final requiresSymbol = _passwordPolicy?['nonAlphanumeric'] ?? true;
final parts = <String>[
tr(
_renderTranslatedText(
'msg.userfront.signup.policy.min_length',
params: {'count': '$minLength'},
values: {'count': '$minLength'},
),
];
if (minTypes > 0) {
parts.add(
tr(
_renderTranslatedText(
'msg.userfront.signup.policy.min_types',
params: {'count': '$minTypes'},
values: {'count': '$minTypes'},
),
);
}
@@ -124,9 +136,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
parts.add(tr('msg.userfront.signup.policy.symbol'));
}
return tr(
return _renderTranslatedText(
'msg.userfront.signup.policy.summary',
params: {'rules': parts.join(", ")},
values: {'rules': parts.join(", ")},
);
}
@@ -688,7 +700,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
tr('msg.userfront.profile.greeting', params: {'name': name}),
_renderTranslatedText(
'msg.userfront.profile.greeting',
fallback: 'Hello, {{name}}.',
values: {'name': name},
),
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,