diff --git a/CHANGELOG.md b/CHANGELOG.md index f3ab235f..8f18017e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.8 + +- Added translation to all hard coded texts. + ## 0.1.7 - Upgraded dependencies. diff --git a/lib/src/controllers/chat/ds_video_message_bubble.controller.dart b/lib/src/controllers/chat/ds_video_message_bubble.controller.dart index a3d40bcf..67226437 100644 --- a/lib/src/controllers/chat/ds_video_message_bubble.controller.dart +++ b/lib/src/controllers/chat/ds_video_message_bubble.controller.dart @@ -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'; @@ -39,8 +40,7 @@ class DSVideoMessageBubbleController { mediaSize, precision: PrecisionValue.One, ) - // TODO: translate - : 'Download'; + : 'video.download'.translate(); } Future getStoredVideo() async { @@ -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: 'video.download-title-error'.translate(), + message: 'video.download-message-error'.translate(), ), ); } finally { diff --git a/lib/src/services/ds_file.service.dart b/lib/src/services/ds_file.service.dart index def8c58f..e3c97718 100644 --- a/lib/src/services/ds_file.service.dart +++ b/lib/src/services/ds_file.service.dart @@ -26,7 +26,7 @@ abstract class DSFileService { return; } - final result = await OpenFilex.open(filePath); + final result = await OpenFilex.open(filePath!); switch (result.type) { case ResultType.done: diff --git a/lib/src/widgets/chat/ds_delivery_report_icon.widget.dart b/lib/src/widgets/chat/ds_delivery_report_icon.widget.dart index b6862617..9f216776 100644 --- a/lib/src/widgets/chat/ds_delivery_report_icon.widget.dart +++ b/lib/src/widgets/chat/ds_delivery_report_icon.widget.dart @@ -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'; @@ -34,7 +35,7 @@ class DSDeliveryReportIcon extends StatelessWidget { case DSDeliveryReportStatus.failed: return DSCaptionSmallText( - 'Falha ao enviar mensagem.', + 'delivery.send-fail'.translate(), color: DSColors.actionColorNegative, ); diff --git a/lib/src/widgets/chat/ds_location_message_bubble.widget.dart b/lib/src/widgets/chat/ds_location_message_bubble.widget.dart index 7c52fdc7..e7706d2c 100644 --- a/lib/src/widgets/chat/ds_location_message_bubble.widget.dart +++ b/lib/src/widgets/chat/ds_location_message_bubble.widget.dart @@ -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'; @@ -155,7 +156,7 @@ class _DSLocationMessageBubbleState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ DSHeadlineLargeText( - 'Selecione uma ação', + 'location.select-action'.translate(), ), DSIconButton( onPressed: () { @@ -197,7 +198,7 @@ class _DSLocationMessageBubbleState extends State { Get.back(); }, title: DSBodyText( - 'Abrir com ${map.mapName}', + "location.open-with".translate() + " ${map.mapName}", ), ); }, diff --git a/lib/src/widgets/chat/ds_reply_container.widget.dart b/lib/src/widgets/chat/ds_reply_container.widget.dart index 67332dcc..33685cd3 100644 --- a/lib/src/widgets/chat/ds_reply_container.widget.dart +++ b/lib/src/widgets/chat/ds_reply_container.widget.dart @@ -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'; @@ -52,7 +53,7 @@ class DSReplyContainer extends StatelessWidget { ), const SizedBox(width: 8.0), DSCaptionText( - 'Reply', + 'reply.text'.translate(), fontStyle: FontStyle.italic, color: style.isLightBubbleBackground(align) ? DSColors.neutralDarkCity @@ -152,7 +153,7 @@ class DSReplyContainer extends StatelessWidget { const SizedBox(width: 8.0), Flexible( child: DSBodyText( - 'Failed to load message', + 'reply.load-fail'.translate(), overflow: TextOverflow.visible, color: _foregroundColor, ), diff --git a/lib/src/widgets/chat/ds_request_location_bubble.widget.dart b/lib/src/widgets/chat/ds_request_location_bubble.widget.dart index c170bc60..342e1191 100644 --- a/lib/src/widgets/chat/ds_request_location_bubble.widget.dart +++ b/lib/src/widgets/chat/ds_request_location_bubble.widget.dart @@ -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'; @@ -56,7 +57,7 @@ class DSRequestLocationBubble extends StatelessWidget { ), if (showRequestLocationButton) DSRequestLocationButton( - label: 'Send Location', // TODO: translate + label: 'location.send'.translate(), ), ], ), diff --git a/lib/src/widgets/chat/ds_show_more_text.widget.dart b/lib/src/widgets/chat/ds_show_more_text.widget.dart index 11f7b3e1..e06ef403 100644 --- a/lib/src/widgets/chat/ds_show_more_text.widget.dart +++ b/lib/src/widgets/chat/ds_show_more_text.widget.dart @@ -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'; @@ -71,8 +72,7 @@ class DSShowMoreText extends StatelessWidget { child: GestureDetector( onTap: () => shouldShowFullText.value = true, child: DSBodyText( - // TODO: Need localized translate. - 'Mostrar mais', + 'show-more.text'.translate(), color: isLightBubbleBackground ? isDefaultBubbleColors ? DSColors.primaryNight diff --git a/lib/src/widgets/chat/ds_survey_message_bubble.widget.dart b/lib/src/widgets/chat/ds_survey_message_bubble.widget.dart index 56b4f4e8..5a5cb3f7 100644 --- a/lib/src/widgets/chat/ds_survey_message_bubble.widget.dart +++ b/lib/src/widgets/chat/ds_survey_message_bubble.widget.dart @@ -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'; @@ -109,19 +110,19 @@ class DSSurveyMessageBubble extends StatelessWidget { _getTitlePreview() { switch (type) { case DSSurveyType.recommendation: - return 'Would you recommend our Chatbot?'; + return "survey.recommendation".translate(); case DSSurveyType.solution: - return 'How did you feel about the service on this channel?'; + return 'survey.solution'.translate(); case DSSurveyType.chatbot: - return 'How did you feel about the chatbot assistance?'; + return 'survey.chatbot'.translate(); } } _getDescriptionPreview(bool positiveLabel) => positiveLabel ? type == DSSurveyType.recommendation - ? 'Recommend' - : 'Positive' + ? 'survey.recommendation-answered-positive'.translate() + : 'survey.positive'.translate() : type == DSSurveyType.recommendation - ? "Don't Recommend" - : 'Negative'; + ? "survey.recommendation-answered-negative".translate() + : 'survey.negative'.translate(); } diff --git a/lib/src/widgets/chat/ds_unsupported_content_message_bubble.widget.dart b/lib/src/widgets/chat/ds_unsupported_content_message_bubble.widget.dart index 9af52391..98daff98 100644 --- a/lib/src/widgets/chat/ds_unsupported_content_message_bubble.widget.dart +++ b/lib/src/widgets/chat/ds_unsupported_content_message_bubble.widget.dart @@ -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'; @@ -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) { @@ -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 ?? 'unsupported-content.text'.translate(), color: color, overflow: overflow, ), diff --git a/lib/src/widgets/chat/video/ds_video_error.dialog.dart b/lib/src/widgets/chat/video/ds_video_error.dialog.dart index cb27bd9e..a4b173a2 100644 --- a/lib/src/widgets/chat/video/ds_video_error.dialog.dart +++ b/lib/src/widgets/chat/video/ds_video_error.dialog.dart @@ -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'; @@ -14,31 +15,29 @@ abstract class DSVideoErrorDialog { required final String url, final Map? 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: 'video-error.reproduction-title'.translate(), + text: 'video-error.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(); diff --git a/lib/src/widgets/fields/ds_phone_input.widget.dart b/lib/src/widgets/fields/ds_phone_input.widget.dart index e2d7769a..bc72bbbb 100644 --- a/lib/src/widgets/fields/ds_phone_input.widget.dart +++ b/lib/src/widgets/fields/ds_phone_input.widget.dart @@ -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'; @@ -209,7 +210,7 @@ class _DSPhoneInputState extends State { border: InputBorder.none, hintText: widget.hintText ?? widget.labelText ?? - 'Número de telefone', + 'phone.number'.translate(), hintStyle: const DSBodyTextStyle( color: DSColors.neutralMediumWave, ), diff --git a/lib/src/widgets/utils/ds_bottomsheet_countries.widget.dart b/lib/src/widgets/utils/ds_bottomsheet_countries.widget.dart index c7b01c12..d038983e 100644 --- a/lib/src/widgets/utils/ds_bottomsheet_countries.widget.dart +++ b/lib/src/widgets/utils/ds_bottomsheet_countries.widget.dart @@ -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'; @@ -40,7 +41,7 @@ abstract class DSBottomSheetCountries { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ DSHeadlineLargeText( - 'País', + 'country.name'.translate(), ), DSIconButton( onPressed: () { @@ -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, diff --git a/pubspec.yaml b/pubspec.yaml index 4424c9a1..94200f6a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: blip_ds description: Blip Design System for Flutter. -version: 0.1.7 +version: 0.1.8 homepage: https://github.com/takenet/blip-ds-flutter#readme repository: https://github.com/takenet/blip-ds-flutter @@ -16,7 +16,7 @@ dependencies: rxdart: ^0.27.4 flutter_spinkit: ^5.1.0 get: ^4.6.5 - open_filex: ^4.3.2 + open_filex: ^4.5.0 path_provider: ^2.1.1 dio: ^5.2.1+1 url_launcher: ^6.1.5 diff --git a/sample/pubspec.lock b/sample/pubspec.lock index 5de2f8b7..eca993ca 100644 --- a/sample/pubspec.lock +++ b/sample/pubspec.lock @@ -31,7 +31,7 @@ packages: path: ".." relative: true source: path - version: "0.1.6" + version: "0.1.8" boolean_selector: dependency: transitive description: @@ -467,10 +467,10 @@ packages: dependency: transitive description: name: open_filex - sha256: "854aefd72dfd74219dc8c8d1767c34ec1eae64b8399a5be317bddb1ec2108915" + sha256: ba425ea49affd0a98a234aa9344b9ea5d4c4f7625a1377961eae9fe194c3d523 url: "https://pub.dev" source: hosted - version: "4.3.2" + version: "4.5.0" package_info_plus: dependency: transitive description: diff --git a/test/widgets/buttons/goldens/ds_pause_button/ds_pause_button.png b/test/widgets/buttons/goldens/ds_pause_button/ds_pause_button.png index e3cc1260..a18b171c 100644 Binary files a/test/widgets/buttons/goldens/ds_pause_button/ds_pause_button.png and b/test/widgets/buttons/goldens/ds_pause_button/ds_pause_button.png differ diff --git a/test/widgets/chat/ds_chat_test.dart b/test/widgets/chat/ds_chat_test.dart index 562c386e..664a155d 100644 --- a/test/widgets/chat/ds_chat_test.dart +++ b/test/widgets/chat/ds_chat_test.dart @@ -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'; @@ -33,7 +34,7 @@ void main() { await tester.pumpWidgetBuilder(messages); final Finder findMessage = find.text( - 'Falha ao enviar mensagem.', // TODO: translate + 'delivery.send-fail'.translate(), findRichText: true, ); diff --git a/test/widgets/chat/goldens/ds_delivery_report_icon/ds_delivery_report_icon.png b/test/widgets/chat/goldens/ds_delivery_report_icon/ds_delivery_report_icon.png index 4776337d..4e766489 100644 Binary files a/test/widgets/chat/goldens/ds_delivery_report_icon/ds_delivery_report_icon.png and b/test/widgets/chat/goldens/ds_delivery_report_icon/ds_delivery_report_icon.png differ