I want to have my text translated and I am using poedit to translate my text.
I am working in ZF2.
I do have my translation file (created with poedit) in place. And that is working.
For example: in this view example the "Sign in" is translated.
(1) {{'Sign in' | trans}}
No I want to add the login view with ng-include, like this:
(2) <div ng-include="'/account/login'"></div>
That works fine too, my login view is there.
But: none of the translations do work in this view. In the login view, this:
(3) <span>{{ 'Password' | trans }}</span>
is not translated. If I add that (3) code however directly after (1), the translation works.
My Question is: how can I ensure that the translations do work when I use a ng-include to add other views?
Hope my question makes sense and that someone knows what to do.
Thanks!
I found a way to solve this.. I think one of the solution is for example:
<div ng-controller="LoginCtrl">
<span>{{ Password }}</span>
</div>
and then on your LoginCtrl should look like this:
app.controller('LoginCtrl', ['$scope', '$translate', function ($scope, $translate) {
// expose translation via `$translate` service
$translate('Password').then(function (password) {
$scope.Password = password;
});
}]);
you may go to this article for more info http://angular-translate.github.io/docs/#/guide/03_using-translate-service#using-$translate-service_things-to-keep-in-mind
Related
I have laravel template.blade.php
<div class="classone">
<div class="classtwo">
text
</div>
<div class="classtwo">
text
</div>
</div>
And I would like to display the code to the user as it is. Incluing new line and indents.
I was playing around with {!! !!}, nl2br(view()->render() even Blade::compileString but was unable to find an elegant solution. Everytime I was able to make it work it was difficult to maintain and every small change to the displayed code was laber intense.
I would like to ask for a suggeston how to display more complex html/css/js code to user. I though it will be fairy often topic but was unable to find anything which would help me.
Thank you in advance.
I tried some things out. They may seem a little bit 'hacky' but I think they will suit your purpose. I used a freshly created Laravel 8 application as an example.
<pre>{{ file_get_contents( resource_path('views/welcome.blade.php')) }}</pre>
You can use the Blade facade to compile your blade file to plain php if you want:
<pre>{{ Blade::compileString(file_get_contents( resource_path('views/app.blade.php'))) }}</pre>
I put <pre></pre> tags around the output to show line breaks. It makes the code more readable.
I have a html form inside one of my views that is supposed to get an image the user uploads and save it, the form is below:
<form class="col-lg-12" action="/banner/store/">
The form itself is quite large, but later on there's a to end it. It was supposed to redirect me to the banner/store where my Banner controller have a dd() function so I can confirm everything is okay. But instead, I get a blank white screen and the url goes banner/store/?.
The routes to the BannerController seems to be correct since banner/create works, the problem is when I go from create to store, but anyways, here's how I set the Routes:
Route::resource('banner', 'BannerController');
Any ideas why my banner/store won't work? And why is there a question mark on the end of the url? Sorry if this may be a dumb error, I'm still learning coding.
Your action is is wrong. When you use the resource static method then the store-url is the same as the GET url.
You can achive your goal with:
<form class="col-lg-12" action="{{ route('banner.store') }}" method="POST">
See more information in documentation.
When you updating your banner, you can't use the browser native form with PUT.
See in this document how laravel will handle that for you.
Let's say that I have the following main view:
<div>
<div>
#yield('content')
</div>
<div>
#include('sidebar')
</div>
<div>
#include('footer')
</div>
</div>
How would I make sure that the included views have their own data? For example, in the sidebar I want to display, let's say, new blog post comments. In the footer I want to display new users and blog posts. Maybe using #include is not the right way to accomplish this?
In your applications, app service providers boot method do something like
View::composer('sidebar',function($view){
$comments= Blog::latest()->comments;
$view->with('comments',$comments);
})
View::composer('footer',function($view){
$users= User::latest();
$view->with('users',$users);
})
//sidebar
Then in the view file do something like
#foreach($comments as $comment)
{{$comment->data}}
#endforeach`
You may want to use View Composers in such case.
Write your logic in View Composer then call it using a service provider, in the boot method
View::composer(
['partials.content', 'partials.sidebar', 'partials.footer], 'App\Http\ViewComposers\MyViewComposer'
);
I'm tried this and it's working with me :
#include('content',array("key"=>"value"))
I just started learning Laravel, and I want to include a second controller into my main layout.
The route is the default root directory: /
And the layout looks like this:
<div class="container">
#yield('content')
</div>
<div class="basket">
~basket comes here~
</div>
I want to show the user's basket, but I need DB queries for that, and I can't find a way to include an other controller, atleast not with routing.
I'm not really asking for code (Sadly i didn't find a better place for this question), probably I just need a designing tip, I really feel I'm trying to do it wrong, since I couldn't find any relevant/helpful information for this.
And I dont want to put the basket into every controller that uses my main layout.
Any kind of help would be apreciated, I'm really lost :)
You should use view composers. Open you AppServiceProvider and inside the boot() method add the following:
view()->composer('your.layout.name', function ($view) {
$basket = ...// Your basket query here
$view->with('basket', basket);
});
This basically says, when view with name your.layout.name is composed, add variable with name $basket.
I'm trying to use ember animated outlet (found here) and, I can not for the life of me get it to work, I understand that instead of using {{outlet}} I need to use {{animated-outlet}} and use {{link-to-aniamted}} instead but it seems to be switching like normal. I also know that I need to include the js after the ember.js and also I am including the css file it comes with, so I'm kind of stumped on this. :(
For my basic view, I'm using
<script type="text/x-handlebars" data-template-name="application">
<div class='wrapper'>
#include('includes.globals.header')
<div class='content row' id='content'>
{{animated-outlet}}
</div>
#include('includes.globals.footer')
#include('includes.js.navigation')
</div>
</script>
and my link looks like:
{{#link-to-animated 'index' animations="main:slideLeft"}} Home #{{/link-to-animated}}
So, is there something i'm missing? Do I need to add something in my app.js? IF you need more code or info, just ask and I will edit this question! Thanks a lot in advance! I'm new to ember, so please take it easy!
You need to specify 'name' in the animated-outlet helper.
{{animated-outlet name="main"}}
The readme explains it: https://github.com/billysbilling/ember-animated-outlet/blob/master/README.md#use-animated-outlet-instead-of-outlet