小编Sho*_*hel的帖子

通过配置在reacti18next中显示键而不是值

我们正在使用reacti18next 来翻译我们的应用程序语言。每个值都根据键显示。但是我们的应用程序中有一个配置是启用空白定位器。启用配置后,翻译将仅显示按键。

假设我们已经实现了翻译键,如下所示,它显示了键的值。现在我们需要显示键名称member-management.members.form.fields.name。我们怎样才能做到这一点?任何想法。

<Trans i18nKey="member-management.members.form.fields.name"/>
Run Code Online (Sandbox Code Playgroud)

i18next reactjs react-i18next

3
推荐指数
1
解决办法
2682
查看次数

在sql server中拆分字符串后获取数组长度

我希望能够在 SQL Server 中拆分字符串。我有一个示例字符串

1012,1012,1012,1012,1012,1012,1012,1012
Run Code Online (Sandbox Code Playgroud)

拆分此字符串后,这里需要长度。

Expected output: 8
Run Code Online (Sandbox Code Playgroud)

sql sql-server sql-server-2012

1
推荐指数
2
解决办法
5099
查看次数

在SQL Server中查找上周的第一天

我有一些日期和星期数,SQL Server中的一周的第一天是5(星期五)。现在,我想从下面的查询中计算上周和上周的开始日期。

DECLARE @LocationID tinyint = 1,
     @FromDate date = '2016-05-20',
     @ToDate date = '2016-05-29';

--Step1: ==================================================================
--SET first day of the week of the year
DECLARE @CurrentDayOfWeek INT
SET DATEFIRST 1 -- normalize current dkoray of week to Monday
SET @CurrentDayOfWeek = DATEPART(DW, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0))
SET DATEFIRST @CurrentDayOfWeek -- first day of week is now 5 (Friday)

--SELECT @CurrentDayOfWeek

-----Get Weekend number--------------
DECLARE @WeekStart int, @WeekEnd int

SET @WeekStart=(SELECT { fn WEEK( @FromDate) })
SET @WeekEnd=(SELECT …
Run Code Online (Sandbox Code Playgroud)

sql sql-server sql-server-2012

0
推荐指数
1
解决办法
2015
查看次数

属性转为 JSON

我有一个包含以下文本的属性文件

var propertiesString = `
alerts.attachment-preview-unavailable=Preview unavailable for this file.
alerts.operation-failed-unknown=Oops, operation failed for unknown reason.
comments.actions.approve.all.success=All comments in this discussion are approved.
comments.actions.approve.one.success=Comment approved.
comments.members.phrases.someone-plus-others={{someone}} + {{countOthers}} others
`;
Run Code Online (Sandbox Code Playgroud)

现在我正在尝试将这些属性转换为 JSON 对象,如下所示

{
  "alerts": {
    "attachment-preview-unavailable": "Preview unavailable for this file.",
    "operation-failed-unknown": "Oops, operation failed for unknown reason."
  },
  "comments": {
    "actions": {
      "approve": {
        "all": {
          "success": "All comments in this discussion are approved."
        },
        "one": {
          "success": "Comment approved."
        }
      }
    },
    "members": {
      "phrases": {
        "someone-plus-others": …
Run Code Online (Sandbox Code Playgroud)

javascript typescript

0
推荐指数
1
解决办法
1547
查看次数

从外部控制函数调用 Angular 方法

我正在使用 ng-select 的标签功能,但当我从控制函数调用角度分量方法时遇到问题。我想this.isValidTag(tag)打电话this.modalService.warnaddTagFn(tag)

这是 html 模板

<div class="modal-header">
  <h5 class="modal-title">{{ headingKey | translate }}</h5>
  <button type="button" class="close" attr.aria-label="{{ 'common.actions.close' | translate }}"
    (click)="activeModal.dismiss()">
    <span aria-hidden="true">&times;</span>
  </button>
</div>
<div class="modal-body p-0">
  <div class="input-group">
    <label class="input-group-prepend" for="tag-keywords"><i class="fa fa-search" aria-hidden="true"></i></label>
    <ng-select labelForId="tag-keywords" [items]="tagsFound" notFoundText="{{ 'common.not-found' | translate }}"
      class="tag-keywords" loadingText="{{ 'common.loading' | translate }}" [hideSelected]="true" [selectOnTab]="true"
      multiple="true" bindLabel="name" [loading]="searching" [addTag]="addTagFn"
      (focus)="onTagFocus()" (search)="onTagSearch($event.term)" [(ngModel)]="selectedTags">
      <ng-template ng-tag-tmp let-search="searchTerm">
        <strong>{{ 'ideas.tags.form.create' | translate }}</strong>{{search}}
      </ng-template>
    </ng-select>
  </div>
  <div class="tag-search-results"></div>
</div> …
Run Code Online (Sandbox Code Playgroud)

angular-ngselect angular

0
推荐指数
1
解决办法
1063
查看次数