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

[Feature] #700110 - DS Internationalization #273

Merged
merged 7 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:crypto/crypto.dart';
import 'package:file_sizes/file_sizes.dart';
import 'package:get/get.dart';

import '../../extensions/ds_localization.extension.dart';
import '../../models/ds_toast_props.model.dart';
import '../../services/ds_file.service.dart';
import '../../services/ds_media_format.service.dart';
Expand Down Expand Up @@ -39,8 +40,7 @@ class DSVideoMessageBubbleController {
mediaSize,
precision: PrecisionValue.One,
)
// TODO: translate
: 'Download';
: 'message.download'.translate();
}

Future<void> getStoredVideo() async {
Expand Down Expand Up @@ -113,11 +113,10 @@ class DSVideoMessageBubbleController {
} catch (_) {
hasError.value = true;

// TODO: translate
DSToastService.error(
DSToastProps(
title: 'Erro ao baixar vídeo',
message: 'Ops! Houve um erro ao baixar o vídeo para reprodução.',
title: 'message.download-title-error'.translate(),
message: 'message.download-message-error'.translate(),
),
);
} finally {
Expand Down
3 changes: 2 additions & 1 deletion lib/src/widgets/chat/ds_delivery_report_icon.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

import '../../enums/ds_delivery_report_status.enum.dart';
import '../../extensions/ds_localization.extension.dart';
import '../../themes/colors/ds_colors.theme.dart';
import '../../themes/icons/ds_icons.dart';
import '../../utils/ds_utils.util.dart';
Expand Down Expand Up @@ -34,7 +35,7 @@ class DSDeliveryReportIcon extends StatelessWidget {

case DSDeliveryReportStatus.failed:
return DSCaptionSmallText(
'Falha ao enviar mensagem.',
'message.send-fail'.translate(),
color: DSColors.actionColorNegative,
);

Expand Down
5 changes: 3 additions & 2 deletions lib/src/widgets/chat/ds_location_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:map_launcher/map_launcher.dart';

import '../../enums/ds_align.enum.dart';
import '../../enums/ds_border_radius.enum.dart';
import '../../extensions/ds_localization.extension.dart';
import '../../models/ds_message_bubble_style.model.dart';
import '../../models/ds_reply_content.model.dart';
import '../../services/ds_auth.service.dart';
Expand Down Expand Up @@ -155,7 +156,7 @@ class _DSLocationMessageBubbleState extends State<DSLocationMessageBubble> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
DSHeadlineLargeText(
'Selecione uma ação',
'message.select-action'.translate(),
),
DSIconButton(
onPressed: () {
Expand Down Expand Up @@ -197,7 +198,7 @@ class _DSLocationMessageBubbleState extends State<DSLocationMessageBubble> {
Get.back();
},
title: DSBodyText(
'Abrir com ${map.mapName}',
"message.open-with".translate() + " ${map.mapName}",
),
);
},
Expand Down
5 changes: 3 additions & 2 deletions lib/src/widgets/chat/ds_reply_container.widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';

import '../../enums/ds_align.enum.dart';
import '../../extensions/ds_localization.extension.dart';
import '../../models/ds_message_bubble_style.model.dart';
import '../../models/ds_reply_content.model.dart';
import '../../themes/colors/ds_colors.theme.dart';
Expand Down Expand Up @@ -52,7 +53,7 @@ class DSReplyContainer extends StatelessWidget {
),
const SizedBox(width: 8.0),
DSCaptionText(
'Reply',
'message.reply'.translate(),
fontStyle: FontStyle.italic,
color: style.isLightBubbleBackground(align)
? DSColors.neutralDarkCity
Expand Down Expand Up @@ -152,7 +153,7 @@ class DSReplyContainer extends StatelessWidget {
const SizedBox(width: 8.0),
Flexible(
child: DSBodyText(
'Failed to load message',
'message.load-fail'.translate(),
overflow: TextOverflow.visible,
color: _foregroundColor,
),
Expand Down
3 changes: 2 additions & 1 deletion lib/src/widgets/chat/ds_request_location_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';

import '../../enums/ds_align.enum.dart';
import '../../enums/ds_border_radius.enum.dart';
import '../../extensions/ds_localization.extension.dart';
import '../../models/ds_message_bubble_style.model.dart';
import '../../models/ds_reply_content.model.dart';
import '../../utils/ds_bubble.util.dart';
Expand Down Expand Up @@ -56,7 +57,7 @@ class DSRequestLocationBubble extends StatelessWidget {
),
if (showRequestLocationButton)
DSRequestLocationButton(
label: 'Send Location', // TODO: translate
label: 'message.send-location'.translate(),
),
],
),
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widgets/chat/ds_show_more_text.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:get/state_manager.dart';

import '../../enums/ds_align.enum.dart';
import '../../extensions/ds_localization.extension.dart';
import '../../models/ds_message_bubble_style.model.dart';
import '../../themes/colors/ds_colors.theme.dart';
import '../../themes/texts/styles/ds_body_text_style.theme.dart';
Expand Down Expand Up @@ -71,8 +72,7 @@ class DSShowMoreText extends StatelessWidget {
child: GestureDetector(
onTap: () => shouldShowFullText.value = true,
child: DSBodyText(
// TODO: Need localized translate.
'Mostrar mais',
'message.show-more'.translate(),
color: isLightBubbleBackground
? isDefaultBubbleColors
? DSColors.primaryNight
Expand Down
15 changes: 8 additions & 7 deletions lib/src/widgets/chat/ds_survey_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import '../../enums/ds_align.enum.dart';
import '../../enums/ds_border_radius.enum.dart';
import '../../enums/ds_survey_scale.enum.dart';
import '../../enums/ds_survey_type.enum.dart';
import '../../extensions/ds_localization.extension.dart';
import '../../models/ds_message_bubble_style.model.dart';
import '../../themes/colors/ds_colors.theme.dart';
import '../../themes/icons/ds_icons.dart';
Expand Down Expand Up @@ -109,19 +110,19 @@ class DSSurveyMessageBubble extends StatelessWidget {
_getTitlePreview() {
switch (type) {
case DSSurveyType.recommendation:
return 'Would you recommend our Chatbot?';
return "message.survey-recommendation".translate();
case DSSurveyType.solution:
return 'How did you feel about the service on this channel?';
return 'message.survey-solution'.translate();
case DSSurveyType.chatbot:
return 'How did you feel about the chatbot assistance?';
return 'message.survey-chatbot'.translate();
}
}

_getDescriptionPreview(bool positiveLabel) => positiveLabel
? type == DSSurveyType.recommendation
? 'Recommend'
: 'Positive'
? 'message.survey-recommendation-answered-positive'.translate()
: 'message.survey-positive'.translate()
: type == DSSurveyType.recommendation
? "Don't Recommend"
: 'Negative';
? "message.survey-recommendation-answered-negative".translate()
: 'message.survey-negative'.translate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';

import '../../enums/ds_align.enum.dart';
import '../../enums/ds_border_radius.enum.dart';
import '../../extensions/ds_localization.extension.dart';
import '../../models/ds_message_bubble_style.model.dart';
import '../../models/ds_reply_content.model.dart';
import '../../themes/colors/ds_colors.theme.dart';
Expand All @@ -27,7 +28,7 @@ class DSUnsupportedContentMessageBubble extends StatelessWidget {
this.overflow = TextOverflow.ellipsis,
this.borderRadius = const [DSBorderRadius.all],
DSMessageBubbleStyle? style,
}) : style = style ?? DSMessageBubbleStyle();
}) : style = style ?? DSMessageBubbleStyle();

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -55,8 +56,7 @@ class DSUnsupportedContentMessageBubble extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.only(left: 8.0),
child: DSBodyText(
text ??
'Unsupported content', // TODO: Need localized translate.
text ?? 'message.unsupported'.translate(),
color: color,
overflow: overflow,
),
Expand Down
37 changes: 18 additions & 19 deletions lib/src/widgets/chat/video/ds_video_error.dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:get/get.dart';

import '../../../extensions/ds_localization.extension.dart';
import '../../../services/ds_dialog.service.dart';
import '../../../services/ds_file.service.dart';
import '../../../utils/ds_directory_formatter.util.dart';
Expand All @@ -14,31 +15,29 @@ abstract class DSVideoErrorDialog {
required final String url,
final Map<String, String?>? httpHeaders,
}) async {
// TODO: translate
await DSDialogService(
title: 'Erro ao reproduzir o vídeo',
text:
'Encontramos um erro ao reproduzir o vídeo. Você deseja tentar abrir o vídeo externamente?',
title: 'message.error-video-reproduction-title'.translate(),
text: 'message.error-video-reproduction-message'.translate(),
primaryButton: DSPrimaryButton(
onPressed: () async {
Get.back();
onPressed: () async {
Get.back();

final cachePath = await DSDirectoryFormatter.getCachePath(
type: 'video/mp4',
filename: md5.convert(utf8.encode(Uri.parse(url).path)).toString(),
);
final cachePath = await DSDirectoryFormatter.getCachePath(
type: 'video/mp4',
filename:
md5.convert(utf8.encode(Uri.parse(url).path)).toString(),
);

await DSFileService.open(
url: url,
path: cachePath,
httpHeaders: httpHeaders,
);
},
label: 'Sim',
),
await DSFileService.open(
url: url,
path: cachePath,
httpHeaders: httpHeaders,
);
},
label: 'message.yes'.translate()),
secondaryButton: DSSecondaryButton(
onPressed: () => Get.back(),
label: 'Não',
label: 'message.no'.translate(),
),
context: Get.context!,
).showError();
Expand Down
3 changes: 2 additions & 1 deletion lib/src/widgets/fields/ds_phone_input.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';

import '../../extensions/ds_localization.extension.dart';
import '../../models/ds_country.model.dart';
import '../../themes/colors/ds_colors.theme.dart';
import '../../themes/icons/ds_icons.dart';
Expand Down Expand Up @@ -209,7 +210,7 @@ class _DSPhoneInputState extends State<DSPhoneInput> {
border: InputBorder.none,
hintText: widget.hintText ??
widget.labelText ??
'Número de telefone',
'phone.number'.translate(),
hintStyle: const DSBodyTextStyle(
color: DSColors.neutralMediumWave,
),
Expand Down
5 changes: 3 additions & 2 deletions lib/src/widgets/utils/ds_bottomsheet_countries.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';

import '../../extensions/ds_localization.extension.dart';
import '../../models/ds_country.model.dart';
import '../../services/ds_bottom_sheet.service.dart';
import '../../themes/colors/ds_colors.theme.dart';
Expand Down Expand Up @@ -40,7 +41,7 @@ abstract class DSBottomSheetCountries {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
DSHeadlineLargeText(
'País',
'country.name'.translate(),
),
DSIconButton(
onPressed: () {
Expand All @@ -64,7 +65,7 @@ abstract class DSBottomSheetCountries {
child: Obx(
() => DSSearchInput(
iconBackgroundColor: Colors.transparent,
hintText: 'Buscar por nome do país ou código',
hintText: 'country.search'.translate(),
onSearch: _onSearch,
onClear: _onClear,
showSuffixIcon: showClearButton.value,
Expand Down
3 changes: 2 additions & 1 deletion test/widgets/chat/ds_chat_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:blip_ds/blip_ds.dart';
import 'package:blip_ds/src/extensions/ds_localization.extension.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:golden_toolkit/golden_toolkit.dart';

Expand Down Expand Up @@ -33,7 +34,7 @@ void main() {
await tester.pumpWidgetBuilder(messages);

final Finder findMessage = find.text(
'Falha ao enviar mensagem.', // TODO: translate
'message.send-fail'.translate(),
findRichText: true,
);

Expand Down
Loading