Wednesday, October 21, 2015

Multilingual Support for AngularJS

There are some cases in which providing a multilingual support is required. Sometimes it could be a good idea to provide support for different languages into the application you’re building and offer your users the possibility to view the content in different idioms. In this tutorial I’ll show you how to add a multilingual support to any AngularJS application.

We’ll build a single page application that requires a multilingual support with more than one language using AngularJS, so the user can switch instantly between languages without refreshing the page. In that case we need to do more things to our application, including translating its text, switching instantly between different languages, or changing the layout direction (RTL > LTR).

All the code developed in this article is available on GitHub.

Environment Setup

In the example I’m going to show you, I'll use Bower and Gulp to make our development environment as more automated and flexible as possible.

Continue reading %Multilingual Support for AngularJS%


by Ahmad Ajmi via SitePoint

Error Handling in Swift 2

How to Create Your Own Browser with JavaScript Using EdgeHTML

This article is part of a web development series from Microsoft. Thank you for supporting the partners who make SitePoint possible.

Over the past several months, we have made numerous improvements to the Microsoft Edge rendering engine (Microsoft EdgeHTML), focusing on interoperability with modern browsers and compliance with new and emerging standards. In addition to powering Microsoft Edge, EdgeHTML is also available for all Universal Windows Platform (UWP) apps via the WebView control. In this tutorial, I’d like to demonstrate how the WebView control can be used to create your own browser in Windows 10. If you’re on Mac, you can always try one of our virtual machines or duel-boot install an Insider build too.

Using standard web technology including JavaScript, HTML, and CSS we created a sample UWP application which hosts the WebView and provides basic functionality such as navigation and favorites. These same techniques can be used in any UWP application to seamlessly integrate web content.

Sample UWP application

Continue reading %How to Create Your Own Browser with JavaScript Using EdgeHTML%


by Josh Rennert via SitePoint

3D Cube CountDown Script

Cube CountDown script takes advantage of CSS3's transform property to display 3D cubes that rotate to count down to any desired future date. It supports either a horizontal or vertical layout, with its interface scalable on different screen sizes.


by via jQuery-Plugins.net RSS Feed

Simple Icons

opl-small

'Simple Icons' is an incredibly useful and well laid out One Pager by Dan Leech that provides popular company logos in SVG format. Very solid free resource this, cheers Dan!

by Rob Hope via One Page Love

Flyweight Design Pattern and Immutability: A Perfect Match

The flyweight pattern is a relatively unknown design pattern in PHP. The fundamental principle behind the flyweight pattern is that memory can be saved by remembering objects after they have been created. Then, if the same objects need to be used again, resources do not have to be wasted recreating them.

Balloon lifting a barbell

You can think of the flyweight pattern as a modification to a conventional object factory. The modification being that rather than just creating new objects all the time, the factory should check to see if it has already created the requested object. If it has, it should return this instance rather than create the object again.

A good use case for the flyweight pattern would be an application that has to load large files. These files would be our flyweight objects.

The Flyweight Object

One important feature of flyweight objects is that they are immutable. This means that they cannot be changed once they have been constructed. This is because our factory can only guarantee that it has remembered the correct object if it can also guarantee that the object it originally created has not been modified.

Below is a very simple example flyweight object for a file. We can tell that it is immutable because the ‘data’ property cannot be changed after the constructor has been called. There is no ‘setData’ method.

class File
{
    private $data;

    public function __construct($filePath)
    {
        // Check to make sure the file exists
        if (!file_exists($filePath)) {
            throw new InvalidArgumentException('File does not exist: '.$filePath);
        }

        $this->data = file_get_contents($filePath);
    }

    public function getData()
    {
        return $this->data;
    }
}

Continue reading %Flyweight Design Pattern and Immutability: A Perfect Match%


by Andrew Carter via SitePoint

Saving and Loading Player Game Data in Unity

In this tutorial, we’ll learn to implement Save/Load game functionality in our game. We will begin by saving the necessary player-related data such as the level we’re on, where we are, and our example tutorial statistics.

Diskette with gamepad drawn on it

If you need a project for testing, you can use the one at the end of the previous article which dealt with cross-scene saving of data, and it’s perfect for following this tutorial:

Download

Saving Data Between Scenes in Unity - previous article
[GitHub Repository]
[ZIP Download]

If you want to download a finished project, the link is at the end of this article.


Continue reading %Saving and Loading Player Game Data in Unity%


by Zdravko Jakupec via SitePoint