I'm trying to change widget language. especially the name of the months.
self.ctx.translate.use('ru_RU').subscribe(response => {
console.log('response',response)
})
doesn't work :(
Related
I click to button query in antd design table pro
but not working
Thanks
Have you added a specific function to it?
By default, clicking the query button will trigger the synToUrl method, it chains search values into params of the current URL as below:
<ProTable<any>
form={{
syncToUrl: (values, type) => {
if (type === "get") {
return {
...values,
};
}
return values;
},
}}
If you want to make further action, you should create base on that util.
Please provide image or code to make thing clearer. Vậy nha bro!
For my project i use User Plugin and Translate Plugin.
I've added custom new fields to the user and now I want to translate them.
I think I know why it does not work. But find no solution.
Somebody to have idea?
if i add to $model->translatable default fields like 'email', works fine.
i added boot function to my custom plugin with this code
\RainLab\User\Models\User::extend(function ($model) {
$model->implement[] = 'RainLab.Translate.Behaviors.TranslatableModel';
$model->translatable = ['about', 'preview_text'];
});
Hmm,
There is one problem. when you try to add it directly $model->translatable, It seems its treating it like attribute of model.
Try this $model->addDynamicProperty(variable_name, value);
\RainLab\User\Models\User::extend(function ($model) {
$model->implement[] = 'RainLab.Translate.Behaviors.TranslatableModel';
$model->addDynamicProperty('translatable', ['about', 'preview_text']);
// like this ^
});
It should treat it as local variable and it should work.
If any doubts please comment.
Revision [ Final solution ] - solution for : it works for existing fields when we are adding new fields this is not working.
Problem: With translation mechanism is that it listens the backend.form.extendFieldsBefore event for form and then register fields for translation. When we try to register new fields in form using extendFormFields extension, It happens afterward so new added fields are not visible to translation listener. so they are kind of skipped as translation field registration process already been done.
Solution: So for solution we can just add our field before translation registartion happens. luckily translate plugin has lowest -1 priority for listening this event backend.form.extendFieldsBefore so we can register our fields before It so we are good now and our fields can be added before it can process fields for translation.
Code
\Event::listen('backend.form.extendFieldsBefore', function($widget) {
// You should always check to see if you're extending correct model
if (!$widget->model instanceof \RainLab\User\Models\User) {
return;
}
// we will merge current fields with fields we want to add
// we used shorthand + plus operator for this
$widget->tabs['fields'] = $widget->tabs['fields'] + Config::get('rms.secis::user_fields');
// here Config::get('rms.secis::user_fields') is just returning field array
// Fo ref. Ex:
// return [
// 'gender' => [
// 'label' => 'Gender',
// 'tab' => 'Security Island',
// 'type' => 'radio',
// 'options' => [
// 'male' => 'Male',
// 'female' => 'Female'
// ],
// 'span' => 'auto'
// ],
// ];
});
Note: we are adding fields to tab so we are using $widget->tabs['fields'] to add fields to the tabs. If you want to add normal fields or secondary tab fields you can use $widget->fields and $widget->secondaryTabs['fields] respectively.
Yes now translator can see our fields and its processed, It should able to show translation UI in frontend-ui as well.
if any doubts please comment.
#hardik-satasiya
yes, no more errors on frontend, but new problem is, that no translate functions on fields.
Maybe to add jQuery Script to Controller?
Integration without JQuery and October Framework files:
https://octobercms.com/plugin/rainlab-translate
end of documentation
In my app i have three screens login , verifyotp , generatepass. I know how to move from one page to other page eg: Navigator.pushNamed(context, "/theNameOfThePage");.
I have a flow in which i move from login->verifyotp->generatepass my question is now how can i move from generatepass to login page and clearing all the stack.
I am an android developer so in android we have intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);.
How can i achieve same result in flutter!
Full clean of Navigator's history and navigate to new route:
void _logout() {
Navigator.pushNamedAndRemoveUntil(context, "/newRouteName", (r) => false);
}
Use Navigator.popUntil.
void _logout() {
Navigator.popUntil(context, ModalRoute.withName('/login'));
}
To add to Paul Iluhin's answer above, if you want to pass arguments to the new page, just add the arguments after (r) => false. Here is an example.
Navigator.pushNamedAndRemoveUntil(context, "/newRouteName", (r) => false, arguments: {
"arg_1": firstArgument,
"arg_2": secondArgument
});
As others have already mentioned, Navigator.pushNamedAndRemoveUntil is the way to go, but in case if anyone is wondering how to do that using the component type (instead of a string route path), this is how you do it.
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (_)
=> LoginPage()), (route) => false);
I personally prefer using the type name because I change my route path multiple times during the initial development until I reach a stable route name pattern and when I do that, I don't want to do a mass search/replace.
I have an ASP.NET MVC web app and trying to use Bootstrap 3 Datepicker for my "month/year" field like the one in demo here:
https://eonasdan.github.io/bootstrap-datetimepicker/#min-view-mode
In that demo, it only allows users to select "year" and "month". Not "days". I want the same functionality in my app. However, in my app, it works the same on first click but on succeeding clicks it shows the "days" selection view. Setting the viewMode to 'years' doesn't fix the problem.
My model is as follows:
public class FilterViewModel
{
public DateTime? StartMonthYear { get; set; }
...
My view is as follows:
<div class="col-sm-3">
#Html.TextBoxFor(model => model.StartMonthYear, new { #class = "month-picker" })
...
<script type="text/javascript">
$(function () {
$('.month-picker').datetimepicker({
viewMode: 'months',
format: 'MM/YYYY',
useCurrent: false
});
});
</script>
The problem is that viewMode only sets the initial view. However, it seems this particular library doesn't provide any way to actually restrict which views are available.
There's an alternate libary that I personally use, which does give you the ability. It's virtually a drop-in replacement, so you shouldn't have to change much to switch over. However, importantly, it provides minView/maxView options you can utilize:
$(function () {
$('.month-picker').datetimepicker({
startView: 'month',
minView: 'month',
format: 'mm/yyyy'
});
});
As you can see there's a few minor differences:
viewMode becomes startView. The view names are also singular month vs. months.
The formatting string is more similar to C# formatting, so you'd use lowercase mm and yyyy.
The default for this library is to use the current date/time, so there's no need for a separate useCurrent option. If you want to specify a different start date/time, you'd use initialDate.
I found a work around which works pretty well:
$(function () {
$('.month-picker').datetimepicker({
viewMode: 'months',
format: 'MM/YYYY',
useCurrent: false
});
$('.month-picker').on("dp.show", function (e) {
$(e.target).data("DateTimePicker").viewMode("months");
})
});
This is based on a reply found here.
This was a bug in the library and solved. I faced same problem and solved by simply downloading latest version.
I am using the pure Razor style definition for a Kendo Menu:
#using Kendo.Mvc.UI
#(Html.Kendo().Menu()
.Name("main-menu")
.Items(items1 =>
{
items1.Add().Text("Home").Url(#Url.Action("Index", "Home"));
items1.Add().Text("Movements").Items(subs =>
{
subs.Add().Text("Import Data").Action("Import", "VehicleMovementBatch");
subs.Add().Text("View Movements");
});
items1.Add().Text("Presences");
items1.Add().Text("Billing");
items1.Add().Text("Config").Items(items2 =>
{
items2.Add().Text("Pricing").Action("Index", "PriceRule");
items2.Add().Text("Users");
});
items1.Add().Text("Control");
})
)
I can find absolutely bloody nothing anywhere on all the internets, that even hints how to do do this properly. The closest I have is defining the DataSource in JavaScript object notation, with separators, and assigning it to the grid oj the client side at run time. This is definitely a good example of a case where can only pray to all the gods that the API isn't as superlatively inadequate as the documentation.
This is all you need to do. Figured it out on my own because I couldn't find an answer anywhere on the web.
items1.Add().Text("<hr/>").Encoded(false).Enabled(false);
The < hr / > thing didn't work for me in kendo 2014.1.528
This does:
children.Add().Text("<div class='k-separator'></div>").Encoded(false).Enabled(false);
So an example would be:
items.Add().Text("Menu X").ImageUrl(Url.Content("~/Content/img/menux_16E.png"))
.Items(children =>
{
children.Add().Text("Item 1").ImageUrl(Url.Content("~/Content/img/item1_16E.png"));
children.Add().Text("<div class='k-separator'></div>").Encoded(false).Enabled(false);
children.Add().Text("Item 3").ImageUrl(Url.Content("~/Content/img/item3_16E.png"));
});
To help anyone coming across this issue in the future, you can add a separator directly with the following:
items.Add().Separator(true);
This works since at least v2013.2.918, since that is what I am using.
Justin
I have v2016.3.914 and items.Add().Separator(true); creates an unwanted horizontal scrollbar on an RTL page.
I solved it using this:
inner.Add().Separator(true).HtmlAttributes(new { style = "width: 99%;" });