Extract Angular-gettext annotations from a .cshtml file

I am utilizing Angular-gettext to extract strings from .html and .js files for multi-language translation via my Gruntfile.js:

  grunt.initConfig({
    nggettext_extract: {
      pot: {
        files: {
          'po/template.pot': ['**/*.html', '**/*.cshtml', '**/controller.caseload.js']
        }
      },
    }

However, I am facing an issue where extraction is not working when trying to pull from a .cshtml file.

The problem lies in extracting content from my Header.cshtml file, which serves as the layout for my angular app. The layout includes a header bar displaying user information such as Profile, Preferences, Logout, etc.

Adding

<div translate>Preferences<div>
to my Header.cshtml file does not result in extraction to the .pot file. Yet, if I include the same line in my index.html file, it extracts correctly allowing for translation definition.

Is there a recommended approach to accomplish this using angular-gettext for .cshtml files?

Answer №1

One possible solution is to include the following code in your configuration file.

            options: {
                extensions: {
                    htm: 'html',
                    html: 'html',
                    php: 'html',
                    phtml: 'html',
                    tml: 'html',
                    js: 'js',
                    cshtml: 'html'
                }

It could be that the system is attempting to interpret your template as JavaScript by default.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide to accessing and utilizing environment-specific values during configuration stage

My goal is to deploy my web application across multiple environments. With Continuous Integration, I can automate the generation of a config.json file for each specific environment. This file will include important URLs that need to be used. { "baseUrl" ...

Typescript Angular filters stop functioning properly post minification

I developed an angular filter using TypeScript that was functioning properly until I decided to minify the source code. Below is the original filter: module App.Test { export interface IGroupingFilter extends ng.IFilterService { (name:"group ...

Choose autocomplete feature from an external source within the context of AngularJS

I am currently working on an autocomplete textbox and I stumbled upon this script that I found through my search efforts. .controller('autoCompleteCTRL', function($scope, $rootScope){ $rootScope.searchItems = [ "ActionScript", ...

When attempting to submit a form using AngularJS in conjunction with Rails, an error arises due to the

After the page loads, I encounter a 404 error because the $resource is returning nil for :city_id. I am new to angularjs so any help in explaining this would be greatly appreciated. I am having trouble making the form entries persist because the same $res ...

Is AngularJS primarily a client-side or server-side framework, or does it have elements

Is it possible to connect to the database on the server side? I have experience using it on the client side, but can the same method be used on the server side? If it's not suitable for server-side use, should I go with PHP or Node.js for designing ...

Is it possible to access a form element directly from form.FormController?

Currently, I am developing multiple components (directives) to facilitate form validation. My goal is to make sure that these components are able to recognize the state of the corresponding input element, such as whether it is required or not. For example. ...

The task "grunt-karma.js" is currently being loaded, but unfortunately an error has occurred: SyntaxError - An unexpected identifier was found

Encountering an issue when loading "grunt-karma.js" tasks while all other tasks are loading correctly. This problem started to occur after updating several dependencies, including grunt-karma and karma. Here is the section from my package.json: "grunt-ka ...

Angular list with a repeating group of radio buttons

I have a set of 'options', which consists of the following: {Id: 1, Label: "option 1"}, {Id: 2, Label: "option 2"} Additionally, I have a list of 'products' structured as follows: {Id: 1, Name: "Name 1", Recommend: options[0]}, {Id: ...

Transform the numerical character into a checkbox within a table using AngularJS

In my HTML code, I am utilizing AngularJS to present data in a table. <div ng-controller="CheckCtrl"> <table class="table table-hover data-table sort display"> <thead> <tr> <th class="Serial_"> ...

Are there discrepancies in isolated scopes among browsers, particularly older versions of Chrome, when using AngularJS 1.2rc2?

While testing an application on an outdated version of Chrome (5.0.3), I encountered a strange issue. Essentially, I have a controller set on a directive like this: <div ng-controller="MyController" class="my-directive-with-isolated-scope"> <!-- ...

Struggling to incorporate my provider into the configuration

Inside app/providers/weather.js: angular.module('forecast').provider('Weather', function() { var apiKey; this.setApiKey = function(key) { if(key) apiKey = key; }; this.$get = function() { return { ... // Som ...

Is it necessary to include a promise in the test when utilizing Chai as Promised?

Documentation provided by Chai as Promised indicates the following: Note: when using promise assertions, either return the promise or notify(done) must be used. Examples from the site demonstrate this concept: return doSomethingAsync().should.eventua ...

Steps to export data to Excel in ASP.NET MVC 5 without needing to refresh the page

I am experiencing an issue with exporting data into Excel. Every time I try to press the Export Data to Excel button, the page reloads. Is there a way to prevent this from happening without reloading the entire page? Your assistance would be greatly apprec ...

Leveraging jQuery plugins within an AngularJs application

I am currently trying to implement the tinyColorPicker plugin from here in my Angular app, but I am facing difficulties with it. An error message keeps appearing: TypeError: element.colorPicker is not a function In my index.html file, I have included th ...

What is the best way to monitor AngularJS's $timeout using Jasmine?

I am attempting to monitor the use of $timeout in order to confirm that it has not been executed. In particular, my production code (shown below) utilizes $timeout as a function rather than an object: $timeout(function() { ... }) instead of $timeout.can ...

Retrieve the result set rows and store them in an array as individual objects

I'm attempting to fetch data from a MySQL database using Angular and PHP. My Angular code looks like this: $http({ url: "http://domain.com/script.php", method: "POST", headers: {'Content-Type': 'applica ...

Sort information based on the alphabetical order of words using AngularJS

I'm working with AngularJS and I'm looking to filter data alphabetically in AngularJS. Any assistance would be greatly appreciated! This is the code snippet I've been using: <script src="~/Scripts/angular.min.js"></script> < ...

Encountering the error message 'Invalid cast specified' while using SqlDataReader in MVC

I kindly request not to categorize this inquiry as a DUPLICATE QUESTION. Despite my efforts to follow all the suggested solutions, I am still encountering this error. Is there anyone who can provide insight on where this error originates from? Below is th ...

Refreshing information in the MongoDB database

I found a file named Musicians.js that includes the following code snippet: exports.update = function(req, res) { var id = req.params.id; console.log("ID-->" + id); //I GET CORRECT ID HERE var updates = req.body; //It does not update any records ...

The variable _spPageContextInfo has not been defined, resulting in a ReferenceError

The code in my JavaScript file looks like this: var configNews = { url:_spPageContextInfo.webAbsoluteUrl, newsLibrary: 'DEMONews', listId: '' }; // Attempting to retrieve the List ID $.ajax({ url: configNews.url + "/_a ...