Drupal 8.9.13 Translation | Drupal.t() does not show up string in the interface Translation - drupal-8

Developed a multisite website without being multilingual initially. Now enabling the Multilingual module for the localization purpose. I did enable all the translated four modules like locale, content, config, and interface. Everything working fine as expected except the javascript variable translation.
I did add/attached the below-mentioned dependency libraries in my theme library file(mytheme.libraries.yml) along with my js file(script.js)
dependencies:
- core/jquery
- core/drupal
In my js file ( script.js ) added javascript translation variable inside the Jquery
(function ($, Drupal, drupalSettings) {
//Js for advanced search box width
$(document).ready(function () {
// Text to show when text is collapsed
var readMoreTxt = " ... See More";
Drupal.t(readMoreTxt);
Drupal.t("See More");
});
});
I've cleared the Drush cache, Development -> Performance Cache, however, it is not showing up on the interface translation page.
May I know where I'm doing a mistake?
Much appreciated for a prompt response.

Related

How to add Django Language mode in CodeMirror Plugin of CKEditor?

I'm using CKEditor wysiwyg for creating django templating. Therefore, I come across using codemirror plugin for CKEditor as here. By following installation instruction, the following options available for config as refered here:
config.codemirror = {
// Set this to the theme you wish to use (codemirror themes)
theme: 'default',
[.......................]
// Define the language specific mode 'htmlmixed' for html including (css, xml, javascript), 'application/x-httpd-php' for php mode including html, or 'text/javascript' for using java script only
mode: 'htmlmixed',
[.......................]
// Whether or not to show the showAutoCompleteButton button on the toolbar
showAutoCompleteButton: true
};
However, as above mode options, the languages are limited to html, javascript, and php, that I could not use another language, for my case Django.
I tried to modify the default code mirror plugin of CKEditor at <path to CKEditor>/Plugins/codemirror/plugin.js to add somewhere possible for django language, yet it resulted only in code error.
So, how can I do to add Django language in codemirror plugin of CKEditor? Thanks.
CodeMirror modes are not limited to html, javascript, and php, here is a list of all supported language modes
Make sure you have the Django mode loaded along with xml, htmlmixed modes loaded in this order:
xml mode: https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/mode/xml/xml.js
htmlmixed mode: https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/mode/htmlmixed/htmlmixed.js
django mode: https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/mode/django/django.js
Mode for HTML with embedded Django template markup.:
mode: 'django'

Redirecting to the same page but switched language url, using Nuxt.js and Vue-i18n

I am trying to redirect the user through a method when he clicks on specific buttons to change the language of the application.
These buttons are part of the standard layout of which all the pages of the project are part of so the url can differ based on which .vue page the user is on but the buttons are always the same which means that the redirecting has to be dynamic.
For example the url :
localhost/about
Should be redirected through the method (by pressing the specific button) to :
localhost/bg/about
In the project the pages are inside a folder _locale and imported also from the .vue files outside of this folder as suggested in the Nuxt documentation for localization with Vue-i18n https://nuxtjs.org/examples/i18n/
The same way are implemented the nuxt.config.js , i18n.js middleware, i18n.js plugin and index.js store files.
Since it is a Nuxt.js application and not just a Vue.js one, just committing the mutation of the store through a page changing the locale (the language) doesn't also actually change the language and even if it did ( using this.$i18n.locale = 'bg' for example ) it only changes it for the specific page and with the next navigation it uses again the fallback locale instead, so I am trying to solve it with redirecting which does use then the correct .json file of the language based on the url. I am just trying to find a way for this redirecting to be more dynamic instead of nagigating only back to the home page of each language.
If needed the github repo : https://github.com/alexgil1994/logistics-gls
Steps needed :
npm install
npm run dev
Could it be done in some better way? Is there any example of Regex for such a situation? Is there an easier way than Regex?
All suggestions are welcome.
It's been a long time since I made this question and I had forgotten that I had found a custom workaround so since the time came to implement it again for another project I thought of finally closing the question.
Since I searched again for possible internationalization solutions I found that there are two possible ones (at least) :
1). Custom solution using Nuxt and vue-i18n is to use a method triggered by the user when he/she chooses one of language choices :
changeLanguage(locale) {
// -- Getting the path before starting
var beforePath = this.$nuxt.$router.history.current.path
// -- Removing the previous locale from the url
var result = ''
result = beforePath.replace( "/bg", "" )
result = result.replace( "/gr", "" )
// -- Redirecting to the same page but in the desired language
if ( locale == 'gr' || locale == 'bg' ) {
this.$nuxt.$router.replace({ path: '/' + locale + result })
} else {
if ( result == '/' ) {
this.$nuxt.$router.replace({ path: '/' + locale })
} else {
this.$nuxt.$router.replace({ path: '/' + locale + result })
}
}
}
You can see I am passing in the locale argument which is the language code that was choosen and we use the $nuxt.$router to get the current path.
2). The second solution would be to use nuxt and nuxt-i18n instead. This way one can use the method switchLocalePath as described in the official documentation. Though I haven't really tried (I remember I tried it 8 months ago but had some problems, I probably had implemented it the wrong way). Will give it another go soon.
Hopefully this will be of help to someone else

Foundation 6 Responsive Toggle nav not working

I am doing my first project in Foundation 6 and am having trouble getting the responsive navigation to work. I started with the basic page template that comes with Foundation (installed F6 using CodeKit) then I pasted in the responsive menu code exactly as it appears here http://foundation.zurb.com/sites/docs/responsive-navigation.html#responsive-toggle but when viewed at small screen sizes, the word "menu" appears, but clicking it does nothing.
The Drilldown responsive menu also does not work -- pasted in the drilldown menu code (second example down, on the page referenced above) and what appears is a long long list of links, nothing is collapsed and nothing slides in. There must be a script missing but I have triple-checked and app.js, foundation.js and jquery scripts are loaded. What else am I missing?
First of all sorry for my bad English, did you initialize foundation's javascript?
That can be done with the following code in youre custom javascript file:
$(document).foundation();
I do it with jQuery like this:
$(document).ready(function() {
$(document).foundation();
});
for more information see: Foundation-6 documentation - initializing
and please check if you have the proper file structure for the foundation files, please see the following documentation: Foundation-6 documentation - File Structure
tl;dr: Faulty purifycss configuartion in the gulp.babel.js file.
I also had this problem. My setup:
generator-webapp
webapp's jade recipe
I can get the responsive dropdown menu to work by using the tab and enter key. This means that the relevant js files are being loaded correctly. The navigation 'burger' also does not appear.
Upon using the chrome dev tools to inspect the responsive dropdown menu example from the foundation website, I noticed that style of <button class="menu-icon" type="button" data-toggle=""></button> is being effected by the .menu-icon CSS rule from the scss partial, _menu-icon.scss. Mine wasn't. When I looked, the foundation.scss file from the app/ has the exact same style rule. The converted foundation.css was being served from the .tmp/ folder, but did not have the .menu-icon CSS rule. Then I suspected purifycss again (which I had commented out of the gulp file before and forgot to reset the gulp serve, saw no fix and thus falsely excluded the purifycss rule from the list of suspects).
I set my gulp styles task up like this:
gulp.task('styles', () => {
return gulp.src('app/styles/*.scss')
.pipe($.plumber())
.pipe($.sourcemaps.init())
.pipe($.sass.sync({
outputStyle: 'expanded',
precision: 10,
includePaths: ['.']
}).on('error', $.sass.logError))
.pipe($.autoprefixer({browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']}))
/*Stupidly assumed that purifycss supported jade files as src files*/
.pipe($.purifycss(['app/**/*.js', 'app/*.jade']))
.pipe($.sourcemaps.write())
.pipe(gulp.dest('.tmp/styles'))
.pipe(reload({stream: true}));
});
Which meant that the necessary styles were being deleted (including .menu-icon). I think I will use stylperjade or rearrange the tasks so that I can do this: .pipe($.purifycss(['app/**/*.js', '.tmp/*.jade']))\
Let me know if this was your solution as well

How do I teach WebStorm 9 inspector to recognize Angular Material Design tags/attributes?

Currently, all my angular material HTML attributes are highlighted in yellow with WebStorm 9 (Mac OS X Yosemite) warning: "Attribute [name] is not allowed here".
How can I teach WS to automatically recognize these attributes as valid? I am aware that I can add each one one-by-one to the list of custom attributes, but was hoping that there would be a better way to do this.
UPDATE:
Just wanted to clarify that this issue applies to Angular Material project, and not the AngularJS itself.
You need to add the angular-material.js file as a Library in WebStorm:
Open Preferences (Mac: Cmd+,, Win/Linux: Ctrl+Alt+S)
Go to Languages & Frameworks > JavaScript > Libraries
Click Add and then press the + icon
Find angular-material.js in your node_modules folder
Add a Name and a version and press Ok
Now you will have completions for all elements and attributes that have an #ngdoc documentation in the angular-material source code.
Usage
Start typing and you will see the completions:
Pressing F1 (Ctrl+Q on Win/Linux) will also show some docs, if available in the source code:
Important note
Not all features are properly documented, the following won't show up (unless you already used them) cause they are defined dynamically in a loop, with no #ngdoc for them:
var API_WITH_VALUES = [ "layout", "flex", "flex-order", "flex-offset", "layout-align" ];
var API_NO_VALUES = [ "show", "hide", "layout-padding", "layout-margin" ];
So for these you'd have to add them as a custom attribute (Alt+Enter > "Add flex to custom html attributes").
Environment
Tested on a Mac OS X 10.11.4 using WebStorm 2016.1.1, but this should work for older versions as well.
I am using PHPStorm, which is a sister Project of WebStorm, but it should work the same way.
You maybe need to add the Library:
File
Settings
Languages & Frameworks
Javascript
Librarys
Add here AngularJS
If this does not work, you can add them manually:
Follow this Steps:
File
Default Settings
Editor
Inspection
HTML
Unknown HTML tag attributes
To the right you will see in Options "Custom HTML tag attributes". Enter here the attributes you want to allow.
I highly recomend you to install the Angular.js plugin:
Go to menu File > Settings (or ctrl + alt + S if you're on Windows);
Select Plugins in the window that'll open;
Click in the Browse Repositories button;
Type AngularJS in the search field. Select the plugin;
Click Install Plugin.
The plugin is incumbed to read #ngdoc annotations present in ngMaterial sources and create documentation for their directives.
It seems to support WebStorm and other IDEs, but I could not find it in the plugin registry while filtering by other IDEs. Maybe it'll work inside WebStorm...
Anyway, this is what you get:
You have also a plugin that helps a lot, check it out. It helps a lot
Angular material v2, Teradata covalent v1, Angular flex layout v1 & Material icon live templates
And with the solution provided by #Alex Ilyaev gives a lot of help.
But its no perfect.
Hope it helps.
Currently I don't think that idea's AngularJS plugin understands angular-materials attribute extensions.
It does understand the directives i.e. control click <md-button ...> and the directive (custom tag) is found.
For now you will have to add the attributes af custom attributes in order to get a "green" page.

Get a list of available components

I'm writing an admin tool for a ColdFusion app, and I'd like to provide an autocomplete feature for a field for entering component names. In order to do this, I'd need a list of all of the components in the application. I have the following code to get a list of mappings:
public function getComponentNames() {
var ServiceFactory = CreateObject('java', 'coldfusion.server.ServiceFactory');
return ServiceFactory.runtimeService.getMappings();
}
Is there any better way to get a list of components than crawling the filesystem looking for .cfc files under these paths?
EDIT: This is currently working, but painfully slowly for just a couple of thousand components:
public function getComponents() {
var ServiceFactory = CreateObject('java', 'coldfusion.server.ServiceFactory');
var mappings = ServiceFactory.runtimeService.getMappings();
for (m in mappings) {
var components = DirectoryList(mappings[m], true, 'path', '*.cfc');
writeDump(components);
}
}
In CFML the sense of an "application" is pretty loose. It's more a bunch of files that interact with each other.
As well as scanning all the mappings, you'd also need to scan any directories within the subdirectory structure of the site as well.
Are you not better off - perhaps - writing an extension for Sublime Text or Eclipse or something? You can then leverage their idea of "projects", and you can let the IDE handle the file indexing. You can then just "do stuff" with the file listing the IDE will expose to you via the API. I've never written an IDE extension, so can't be more "helpful" than that, I'm afraid.