Coder Social home page Coder Social logo

Comments (3)

black-rusuz avatar black-rusuz commented on May 28, 2024

That would be very useful. My white-label app needs to override some stings on server-side, but others can be used with the defaults from the RootBundle.

@Chaloemphisit Here's my draft, you may use it:

class CombinedAssetLoader extends SmartNetworkAssetLoader {
  final AssetLoader parent;

  CombinedAssetLoader({
    required this.parent,
    required super.localeUrl,
    super.timeout = const Duration(seconds: 30),
    required super.assetsPath,
    super.localCacheDuration = const Duration(days: 1),
  });

  @override
  Future<Map<String, dynamic>> load(String localePath, Locale locale) async {
    final smartData = await super.load(localePath, locale);
    final parentData = await parent.load(localePath, locale);
    parentData?.addAll(smartData);
    return parentData ?? {};
  }
}

I could rewrite this and open a Pull Request on the easy_localization_loader repository. Maybe create kinda class CombinedAssetLoader extending AssetLoader, that requires arguments with base loader and override loader, and creates merged Map with localized strings.

from easy_localization.

Chaloemphisit avatar Chaloemphisit commented on May 28, 2024

Sorry, but i think this logic will not work for nested map.

image

from easy_localization.

black-rusuz avatar black-rusuz commented on May 28, 2024

Hmmm, that's true. I did this for my project and didn't need it :)
You need to add something like "deep merge": https://gist.github.com/niusounds/30ba030c084ccd11faaab0bf2ecd81cf

from easy_localization.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.