Boulangerie / angular-translate-extract

Manage extraction of angular-translate in your angular projects
MIT License
7 stars 5 forks source link

Translating when translation keys are setup in the controller #17

Open gercheq opened 6 years ago

gercheq commented 6 years ago

What's the best way to make angular-translate-extract work with the following setup?

I'm getting {{ feature.title }} in my en_US.json file instead of seeing all the titles ie. FeatureEventsItem1Title, FeatureEventsItem2Title...

features.controller.js

$scope.eventManagementFeatures = [
                {
                    title: "FeatureEventsItem1Title",
                    subtitle: "FeatureEventsItem1Description",
                    image: HomeFeaturesImagesFolder + "/event_management/event1.png"
                },

                {
                    title: "FeatureEventsItem2Title",
                    subtitle: "FeatureEventsItem2Description",
                    image: HomeFeaturesImagesFolder + "/event_management/event2.png"
                },
                {
                    title: "FeatureEventsItem3Title",
                    subtitle: "FeatureEventsItem3Description",
                    image: HomeFeaturesImagesFolder + "/event_management/event3.png"
                },
                {
                    title: "FeatureEventsItem4Title",
                    subtitle: "FeatureEventsItem4Description",
                    image: HomeFeaturesImagesFolder + "/event_management/event4.png"
                },
                {
                    title: "FeatureEventsItem5Title",
                    subtitle: "FeatureEventsItem5Description",
                    image: HomeFeaturesImagesFolder + "/event_management/event5.png"
                },
                {
                    title: "FeatureEventsItem6Title",
                    subtitle: "FeatureEventsItem6Description",
                    image: HomeFeaturesImagesFolder + "/event_management/event6.png"
                }
            ];

features.html

  <div class="Features-articleItem"
            ng-repeat="feature in eventManagementFeatures">
        <div class="container">
            <div class="row">
                <div class="row-height">
                    <div class="col-sm-4 col-sm-height col-sm-middle">
                        <img ng-src="{{ feature.image }}"/>
                    </div>
                    <div class="col-sm-8 col-sm-height col-sm-middle">
                        <h2 translate="{{ feature.title }}"></h2>
                        <p class="lead" translate="{{ feature.subtitle }}"></p>
                    </div>
                    <div class="col-sm-4 col-sm-height col-sm-middle">
                        <img ng-src="{{ feature.image }}"/>
                    </div>
                </div>
            </div>
        </div>

en_US.json

{
    "HELLO": "Hello",
    "{{ feature.title }}": "",
    "{{ feature.subtitle }}": "",
}