question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to translate controller function objects

See original GitHub issue

en.json

{
  "CHOOSE_IMAGE": "Choose image source",
  "CAMERA": "Camera",
  "LIBRARY": "Library",
  "CANCEL": "Cancel"
}

th.json

{
  "CHOOSE_IMAGE": "เลือกที่มาของภาพ",
  "CAMERA": "กล้อง",
  "LIBRARY": "แกลอรี่",
  "CANCEL": "ยกเลิก"
}

feedback.controller.js

...
            function getImageSource() {
                var deferred = $q.defer();

                $ionicActionSheet.show({
                    buttons: [
                        { text: 'CAMERA' },
                        { text: 'LIBRARY' }
                    ],
                    titleText: 'CHOOSE_IMAGE',
                    cancelText: 'CANCEL',
                    cancel: function () {
                        deferred.reject();
                    },
                    buttonClicked: function (index) {
                        if (index === 0) {
                            deferred.resolve(Camera.PictureSourceType.CAMERA);
                        } else {
                            deferred.resolve(Camera.PictureSourceType.PHOTOLIBRARY);
                        }
                        return true;
                    }
                });

                return deferred.promise;
            }
...

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Delagencommented, May 20, 2016

@danielbair

.controller(["$filter",....],function($filter,....){
var translateFilter=$filter("translate");
...
buttons: [
                        { text: translateFilter('CAMERA') },
                        { text: translateFilter('LIBRARY') }
                    ]
...

})

or when translations isn’t loaded already

.controller(["$q","$translate",....],function($q,$translate,....){
var translateFilter=$filter("translate");

$q.all({
CAMERA:$translate('CAMERA'),
LIBRARY:$translate('CAMERA')
}).then(function(translations){
...
buttons: [
                        { text: translations.CAMERA },
                        { text: translations.LIBRARY }
                    ]
...
})
})
0reactions
knallicommented, May 20, 2016

You will have to use the $translate service. Additionally, there will be found $translate.instant.

If something “breaks”, you will have to show us the break. We cannot guess what you are doing at your place.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to angular-translate controller function objects
Inside the function are system button labels that need to be translated. I have provided the actual en.json and th.json files to show...
Read more >
15.3 Implementing Controllers - Spring
You convert the request body to the method argument by using a HttpMessageConverter . HttpMessageConverter is responsible for converting from the HTTP request ......
Read more >
keckcaves:controllers [CSEWiki]
To “pick up” space, press and hold one grip button on one controller (the two grip buttons on the same controller act as...
Read more >
How to setup a Translate Controller Plugin in Zend Framework 3
First of all, we have to write our plugin that will take Zend Translator object in constructor and will wrap its translate() method....
Read more >
Scripting API: Transform.Translate - Unity - Manual
Declaration. public void Translate(Vector3 translation);. Declaration · Declaration. public void Translate(float x, float y, float z);. Declaration · Declaration.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found