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

Spanish language support #283

Closed
as-stefit opened this issue Mar 5, 2024 · 2 comments
Closed

Spanish language support #283

as-stefit opened this issue Mar 5, 2024 · 2 comments
Labels
good first issue Good for newcomers

Comments

@as-stefit
Copy link

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

@ueman ueman added the good first issue Good for newcomers label Mar 5, 2024
@ueman
Copy link
Owner

ueman commented Mar 5, 2024

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

@TijnvandenEijnde
Copy link

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 .

@ueman ueman closed this as completed Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants