ueman/feedback

Spanish language support

Closed this issue · 2 comments

In my app I'm using spanish language, would be nice to have it as well :)

I don't speak Spanish, so I'm leaving this for someone who does.

You can create a custom class, this way you can add any language you want. This is the class I am using in my application. I am using easy_localization for the translations.

import 'package:easy_localization/easy_localization.dart';
import 'package:feedback/feedback.dart';
import 'package:flutter/material.dart';

class CustomFeedbackLocalizations implements FeedbackLocalizations {
  @override
  String get draw => tr('feedBackPage.draw');

  @override
  String get feedbackDescriptionText => tr('feedBackPage.description');

  @override
  String get navigate => tr('feedBackPage.navigate');

  @override
  String get submitButtonText => tr('feedBackPage.submit');
}

class CustomFeedbackLocalizationsDelegate
    extends GlobalFeedbackLocalizationsDelegate {
  @override
  // ignore: overridden_fields
  final supportedLocales = <Locale, FeedbackLocalizations>{
    const Locale('de'): CustomFeedbackLocalizations(),
    const Locale('en'): CustomFeedbackLocalizations(),
    const Locale('es'): CustomFeedbackLocalizations(),
    const Locale('fr'): CustomFeedbackLocalizations(),
    const Locale('nl'): CustomFeedbackLocalizations(),
    const Locale('pt'): CustomFeedbackLocalizations(),
    const Locale('ru'): CustomFeedbackLocalizations(),
    const Locale('uk'): CustomFeedbackLocalizations(),
  };
}

In your BetterFeedback widget you can use the class like so:

return BetterFeedback(
  localizationsDelegates: [
    ...context.localizationDelegates,
    CustomFeedbackLocalizationsDelegate(),
  ],
  localeOverride: context.locale,
  child: MaterialApp(
    locale: context.locale,
    localizationsDelegates: context.localizationDelegates,
    supportedLocales: context.supportedLocales,
  ),
),

It could be possible that I have forgotten something, please let me know if you need some help @as-stefit .