### Install Application Executable Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Installs the main application executable to the root of the installation bundle. This is part of the runtime component installation. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Installation Configuration Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Configures installation settings, including the destination directory for runtime components and support files, ensuring the application can run in place. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif () set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install Flutter Library Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Installs the main Flutter library file into the lib directory of the installation bundle. This is a required runtime component. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Library Installation Path Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Sets the installation path for bundled libraries relative to the binary, using $ORIGIN for runtime loading. ```cmake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Project Setup and Versioning Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Sets the minimum CMake version and project name. It also explicitly opts into modern CMake behaviors. ```cmake cmake_minimum_required(VERSION 3.14) project(flutter_example LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "flutter_example") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Installs all bundled libraries associated with plugins into the lib directory of the installation bundle. This ensures that plugin dependencies are correctly included for runtime. ```cmake foreach (bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach (bundled_library) ``` -------------------------------- ### Install AOT Library Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library, but only for 'Profile' and 'Release' build configurations. ```cmake # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library and Bundled Plugins Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Installs the Flutter library file and any bundled plugin libraries to the application's runtime directory. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if (PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif () ``` -------------------------------- ### Install Application Target and ICU Data Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Installs the main application executable and the ICU data file to the specified runtime destination. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Bundle Directory Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Sets the installation prefix to a specific bundle directory within the build directory. This is used to create a relocatable bundle for the application. The cache is forced to ensure the setting takes effect. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif () ``` -------------------------------- ### YAML Message File Example Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Define your application messages in a YAML file. This format supports simple strings and parameterized messages. ```yaml button: save: Save load: Load users: welcome(String name): "Hello $name!" logout: Logout ``` -------------------------------- ### Clean Build Bundle Directory on Install Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Removes the build bundle directory recursively before installation. This ensures a clean state for the bundle each time the application is installed. ```cmake install( CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Installs the ICU data file, which is required for internationalization and localization, into the data directory of the installation bundle. This is a runtime component. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Installs the Flutter assets directory, ensuring it's fully re-copied on each build to prevent stale files. It first removes the old directory and then copies the new one. ```cmake # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Pluralization Example in Czech Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Illustrates how to define plural forms for languages like Czech, which require more than two forms (e.g., one, few, many). ```yaml apples: _apples(int cnt): "${_plural(cnt, one:'jablko', few: 'jablka', many:'jablek')}" ``` -------------------------------- ### Install AOT Library (Non-Debug Builds) Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Conditionally installs the AOT (Ahead-Of-Time) compiled library for non-Debug build types. This is typically done to include optimized code in release builds. ```cmake if (NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif () ``` -------------------------------- ### Generated Dart Classes for Messages Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Example of the Dart classes generated by the i18n tool based on the YAML definitions. These classes provide type-safe access to localized messages. ```dart class Messages { const Messages(); InvoiceMessages get invoice => InvoiceExampleMessages(this); ApplesMessages get apples => ApplesExampleMessages(this); } class InvoiceMessages { final Messages _parent; const InvoiceMessages(this._parent); String get create => "Create invoice"; String get help => "Use this function to generate new invoices and stuff. Awesome!"; String get delete => "Delete invoice"; String count(int cnt) => "You have created $cnt ${_plural(cnt, one:'invoice', many:'invoices')}."; } class ApplesMessages { final Messages _parent; const ApplesMessages(this._parent); String _apples(int cnt) => "${_plural(cnt, one:'apple', many:'apples')}"; String count(int cnt) => "You have eaten $cnt ${_apples(cnt)}."; } ``` -------------------------------- ### Add Dependency Libraries and Include Directories Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/runner/CMakeLists.txt Specifies libraries to link against and directories to search for include files. Application-specific dependencies should be added here. ```cmake # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Applies standard C++14 compilation features, warning options, and optimization levels. Use this for consistent build configurations. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") endfunction() ``` -------------------------------- ### Cross-Building Root Filesystem Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Configures the sysroot and find root path for cross-building environments, setting specific modes for program, package, library, and include paths. ```cmake if (FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif () ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/runner/CMakeLists.txt Applies a standard set of build settings to the application target. This can be customized for applications with different build requirements. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Find and check PkgConfig modules for GTK, GLIB, and GIO Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/flutter/CMakeLists.txt This snippet uses PkgConfig to find and check for the required GTK, GLIB, and GIO libraries, which are system-level dependencies for Flutter Linux applications. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Using Generated Message Classes Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Demonstrates how to instantiate and use generated message classes for default and locale-specific translations. The choice of which translation to use is determined by the developer. ```dart import 'messages.i18n.dart'; import 'messages_de.i18n.dart' as de; void main() async { Messages m = Messages(); print(m.apples.count(1)); print(m.apples.count(2)); print(m.apples.count(5)); m = de.Messages_de(); // see? ExampleMessages_cs extends ExampleMessages print(m.apples.count(1)); print(m.apples.count(2)); print(m.apples.count(5)); } ``` -------------------------------- ### Flutter Web Entrypoint Loading Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/web/index.html This snippet configures the Flutter web loader to download the main Dart entrypoint. It includes optional service worker versioning and initializes the Flutter engine to run the application. ```javascript const serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function(engineInitializer) { engineInitializer.initializeEngine().then(function(appRunner) { appRunner.runApp(); }); } }); }); ``` -------------------------------- ### Project and Executable Naming Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Sets the minimum CMake version and the project name. Defines the on-disk name for the application executable. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "flutter_example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.flutter_example") ``` -------------------------------- ### Profile Build Mode Settings Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Configures linker and compiler flags for the 'Profile' build mode, typically by inheriting settings from the 'Release' mode. ```cmake # Define settings for the Profile build mode. set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") ``` -------------------------------- ### Flutter Integration with build_runner Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Shows how to integrate the i18n package into a Flutter project using `build_runner` for automatic generation of message classes from YAML files. This snippet includes the command to watch for changes and rebuild. ```bash flutter packages pub run build_runner watch ``` -------------------------------- ### Unicode Support Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Enables Unicode support for all projects by defining preprocessor macros. ```cmake # Use Unicode for all projects. add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Pluralization Helper Functions Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Demonstrates the usage of helper functions for pluralization, cardinal, and ordinal number formatting. These functions are essential for languages with complex plural rules. ```dart String _plural(int count, {String zero, String one, String two, String few, String many, String other}) String _cardinal(int count, {String zero, String one, String two, String few, String many, String other}) String _ordinal(int count, {String zero, String one, String two, String few, String many, String other}) ``` -------------------------------- ### Set Runtime Output Directory for Executable Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Configures the runtime output directory for the application's executable. This ensures that the executable is placed in a subdirectory to prevent users from running an unbundled copy, as resources must be in the correct relative locations. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Generated Plugin Integration Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Includes CMake rules for generated plugins, which manage building and integrating plugins into the application. ```cmake # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### General Compilation Settings Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Placeholder for general compilation settings that should apply to most targets. New options should typically be added to specific targets. ```cmake # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead ``` -------------------------------- ### One-time Build Command Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Provides the command to perform a one-time build or rebuild of message classes using `build_runner` in a Flutter project. ```bash flutter packages pub run build_runner build ``` -------------------------------- ### Define Flutter Application Target Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Defines the main executable for the Flutter application, including source files and generated plugin registrants. Ensure BINARY_NAME matches the Flutter tool's expectation. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) ``` -------------------------------- ### Basic Message Definitions in YAML Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Define default messages in a YAML file. These serve as the base for all translations. ```yaml generic: ok: OK done: DONE invoice: create: Create invoice delete: Delete invoice ``` -------------------------------- ### Modern CMake Policy Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Explicitly opts into modern CMake behaviors to avoid warnings with recent CMake versions. ```cmake cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Add Preprocessor Definitions for Build Version Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/runner/CMakeLists.txt Adds preprocessor definitions to the build configuration to include Flutter version information. This allows the application to access version details at compile time. ```cmake # Add preprocessor definitions for the build version. target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") ``` -------------------------------- ### Custom command for Flutter tool backend Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/flutter/CMakeLists.txt This custom command executes the Flutter tool backend script to generate necessary build artifacts like the Flutter library and headers. It uses a phony output to ensure execution on every build. ```cmake add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Build Configuration for Multi-Config Generators Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Defines the available build configurations (Debug, Profile, Release) when using a multi-configuration CMake generator. ```cmake get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if (IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else () if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif () endif () ``` -------------------------------- ### Link Application Dependencies Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Links the application target with necessary libraries, including the Flutter engine and GTK. This ensures the application can utilize Flutter and GTK functionalities. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### Define list_prepend function for CMake < 3.10 Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/flutter/CMakeLists.txt This function prepends a prefix to each element in a list. It is used because the list(TRANSFORM ... PREPEND ...) command is not available in CMake version 3.10. ```cmake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach (element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach (element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ``` -------------------------------- ### Define Application Target Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/runner/CMakeLists.txt Defines the main executable target for the Windows runner application. Source files and resources are listed here. The binary name is controlled by the top-level CMakeLists.txt. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) ``` -------------------------------- ### Include Generated Plugin Build Rules Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Includes the CMake script responsible for managing the building of Flutter plugins and adding them to the application. This is essential for integrating third-party or custom plugins into the Flutter project. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Standard Compilation Settings Function Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Defines a reusable function to apply standard compilation features and options to a target, including C++17 support and specific warning/exception settings. ```cmake # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$:_DEBUG") endfunction() ``` -------------------------------- ### Message Definitions with Parameters and Pluralization Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Define messages that accept parameters and use pluralization rules. The `_plural` helper function is used to handle different forms based on a count. ```yaml invoice: create: Create invoice delete: Delete invoice help: "Use this function to generate new invoices and stuff. Awesome!" count(int cnt): "You have created $cnt ${_plural(cnt, one:'invoice', many:'invoices')}." apples: _apples(int cnt): "${_plural(cnt, one:'apple', many:'apples')}" count(int cnt): "You have eaten $cnt ${_apples(cnt)}." ``` -------------------------------- ### Subdirectory Inclusion Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/CMakeLists.txt Includes the Flutter managed directory and the runner subdirectory, which contain specific build rules for the Flutter framework and the application's runner. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") ``` -------------------------------- ### Add Flutter Tool Build Dependency Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/runner/CMakeLists.txt Ensures that the Flutter tool's assembly process is completed before the application target is built. This dependency is crucial and must not be removed. ```cmake # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Build Configuration Default Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Sets the default build type to 'Debug' if not already defined, ensuring a consistent build mode for Flutter applications. ```cmake if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif () ``` -------------------------------- ### Using Generated Messages in Flutter Widget Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Illustrates how to import and use a generated message class within a Flutter widget to display translated text. ```dart import 'packages:my_app/messages/foo.i18n.dart' ... Foo m = Foo(); return Text(m.bar); ... ``` -------------------------------- ### Add Flutter Assemble Dependency Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/CMakeLists.txt Ensures that the Flutter assembly process is completed before the application target is built. This is a mandatory step for Flutter applications. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Basic Usage of Generated Messages Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Instantiate and use the generated message classes to access localized strings. The default messages are used when no specific locale is provided. ```dart Messages m = Messages(); print(m.generic.ok); // output: OK print(m.generic.done); // output: DONE m = Messages_de(); print(m.generic.ok); // output: OK print(m.generic.done); // output: ERLEDIGT ``` -------------------------------- ### Define Flutter library interface target Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/linux/flutter/CMakeLists.txt This section defines an INTERFACE library target for Flutter, specifying include directories and linking against the Flutter shared object and system libraries (GTK, GLIB, GIO). ```cmake list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### German Translations in YAML Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Provide translations for specific languages by creating separate YAML files. The filename indicates the language code (e.g., `_de` for German). ```yaml generic: ok: OK done: ERLEDIGT invoice: create: Rechnung erstellen delete: Rechnung löschen ``` -------------------------------- ### Using Generated Classes in Dart Source: https://github.com/mohiuddinm/i18n/blob/master/README.md Instantiate the generated Messages class and use its properties and methods to access localized strings. Parameterized messages can be called directly. ```dart Messages m = Messages(); print(m.users.welcome('World')); // outputs: Hello World! ``` -------------------------------- ### Generated Dart Classes Source: https://github.com/mohiuddinm/i18n/blob/master/README.md The i18n package generates Dart classes based on the provided YAML message files. These classes provide convenient access to localized strings and functions. ```dart class Messages { const Messages(); ButtonMessages get button => ButtonExampleMessages(this); UsersMessages get users => UsersExampleMessages(this); } class ButtonMessages { final Messages _parent; const ButtonMessages(this._parent); String get save => "Save"; String get load => "Load"; } class UsersMessages { final Messages _parent; const UsersMessages(this._parent); String get logout => "Logout"; String welcome(String name) => "Hello $name!"; } ``` -------------------------------- ### Disable Conflicting Windows Macros Source: https://github.com/mohiuddinm/i18n/blob/master/flutter_example/windows/runner/CMakeLists.txt Disables Windows-specific macros (NOMINMAX) that might conflict with C++ standard library functions, preventing potential compilation errors. ```cmake # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.