GithubHelp home page GithubHelp logo

material-foundation / material-internationalization-ios Goto Github PK

View Code? Open in Web Editor NEW
41.0 12.0 35.0 886 KB

MDFInternationalization assists in internationalizing your IOS app or components.

License: Apache License 2.0

Ruby 1.11% Objective-C 83.21% Shell 5.27% Starlark 10.41%

material-internationalization-ios's Introduction

MDFInternationalization

MDFInternationalization assists in internationalizing your iOS app or components' user interface.

License GitHub release Build Status CocoaPods Compatible Carthage compatible

Right-to-Left calculations for CGRects and UIEdgeInsets

A UIView is positioned within its superview in terms of a frame (CGRect) consisting of an origin and a size. When a device is set to a language that is written from Right-to-Left (RTL), we often want to mirror the interface around the vertical axis. This library contains functions to assist in modifying frames and edge insets for RTL.

// To flip a subview's frame horizontally, pass in subview.frame and the width of its parent.
CGRect originalFrame = childView.frame;
CGRect flippedFrame = MDFRectFlippedHorizontally(originalFrame, CGRectGetWidth(self.bounds));
childView.frame = flippedFrame;

Mirroring Images

A category on UIImage backports iOS 10's [UIImage imageWithHorizontallyFlippedOrientation] to earlier versions of iOS.

// To mirror on image, invoke mdf_imageWithHorizontallyFlippedOrientation.
UIImage *mirroredImage = [originalImage mdf_imageWithHorizontallyFlippedOrientation];

Adding semantic context

A category on UIView backports iOS 9's -[UIView semanticContentAttribute] and iOS 10's -[UIView effectiveUserInterfaceLayoutDirection] to earlier versions of iOS.

// To set a semantic content attribute, set the mdf_semanticContentAttribute property.
lockedLTRView.mdf_semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;

// mdf_semanticContentAttribute is used to calculate the mdf_effectiveUserInterfaceLayoutDirection
if (customView.mdf_effectiveUserInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
  // Update customView's layout to be in RTL mode.
}

Embedding Bi-directional strings

A category on NSString offers a simple API to wrap strings in Unicode markers so that LTR and RTL text can co-exist in the same string.

// To embed an RTL string in an existing LTR string we should wrap it in Unicode directionality
// markers to  maintain preoper rendering.

// The name of a restaurant is in Arabic (RTL), but the rest of string is in Latin (LTR).
NSString *wrappedRestaurantName =
    [restaurantName mdf_stringWithStereoReset:NSLocaleLanguageDirectionRightToLeft
                                      context:NSLocaleLanguageDirectionLeftToRight];

NSString *reservationString = [NSString stringWithFormat:@"%@ : %ld", wrappedRestaurantName, attendees];

Usage

See Examples/Flags for a detailed example of how to use the functionality provided by this library.

License

MDFInternationalization is licensed under the Apache License Version 2.0.

material-internationalization-ios's People

Contributors

ajsecord avatar andrewoverton avatar codeman7 avatar dmaclach avatar ianegordon avatar jverkoey avatar willlarche avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

material-internationalization-ios's Issues

Silence partial implementation warnings introduced in Xcode 9

One example:
MDFInternationalization/Sources/UIImage+MaterialRTL.m:130:18: warning: 'imageWithHorizontallyFlippedOrientation' is only available on iOS 10.0 or newer [-Wunguarded-availability]
return [self imageWithHorizontallyFlippedOrientation];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Cocoapods Image not found

I have the following error coming up when opening interface builder in XCode 9:

IB Designables: Failed to render and update auto layout status for SignUpNameViewController (Qyv-Q3-9tM): dlopen(MaterialComponents.framework, 1): Library not loaded: @rpath/MDFInternationalization.framework/MDFInternationalization
Referenced from: MaterialComponents.framework
Reason: image not found

Any way to fix it ?

Create Symlinks to Header Folders

Hi,

We receive this error when building app.

Please see here

warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'MDFInternationalization' from project 'Pods')

The MDFInternationalization bazel target needs to depend on MDFInternationalizationFrameworkHeaders

When using bazel to depend on MDFInternationalization 1.1.0 we get the following build failure:

ERROR: components/Tabs/BUILD:103:1: C++ compilation of rule '//components/Tabs:unit_test_sources' failed (Exit 1)
components/Tabs/tests/unit/MDCTabBarLayoutTests.m:15:9: fatal error: 'MDFInternationalization/MDFInternationalization.h' file not found
#import <MDFInternationalization/MDFInternationalization.h>

This is due to the library using framework style imports but not depending on the MDFInternationalizationFrameworkHeaders target which provides support for this style of imports.

We likely need to depend on MDFInternationalizationFrameworkHeaders from MDFInternationalization

Bazel improvements

  • WORKSPACE should use http_archive instead of git_repository
  • Bump build_bazel_rules_apple to 0.1.0.

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.