Skip to content

加了一个小驼峰的转换,将velocityTool.leftPadZeros的中文说明补齐了 #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/main/java/com/shuzijun/leetcode/plugin/utils/VelocityTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,36 @@ public static String camelCaseName(String underscoreName) {
}
}

public static String smallCamelCaseName(String underscoreName) {

if (isNotBlank(underscoreName)) {
underscoreName = underscoreName.replace(" ", "_");
StringBuilder result = new StringBuilder();
if (isNumeric(underscoreName.substring(0, 1))) {
underscoreName = numsAry[Integer.valueOf(underscoreName.substring(0, 1))] + "-" + underscoreName.substring(1);
}
boolean first = false;
boolean flag = false;
for (int i = 0; i < underscoreName.length(); i++) {
char ch = underscoreName.charAt(i);
if ('_' == ch || '-' == ch) {
flag = true;
} else {
if (flag || first) {
result.append(Character.toUpperCase(ch));
flag = false;
first = false;
} else {
result.append(ch);
}
}
}
return result.toString();
} else {
return underscoreName;
}
}


public static String snakeCaseName(String underscoreName) {

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/i18n/info.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ report=Report to plugin developer
donate.info=Donation
updata=Leetcode Editor new version {0} is found. Please update the plugin
user.email=YOU HAVE NOT VERIFIED YOUR ACCOUNT\nYou cannot submit your code to the judge system until you verify your email.\nYou may resend the verification email or change your email in your profile page.
template.variable=${0}question.title{1}\tquestion title\tex:Two Sum\n${0}question.titleSlug{1}\tquestion title slug \tex:two-sum\n${0}question.frontendQuestionId{1}\tquestion serial number\n${0}question.content{1}\tquestion content\n${0}question.code{1}\tquestion code\n$!velocityTool.camelCaseName(str)\ttransform str camel case\n$!velocityTool.snakeCaseName(str)\ttransform str snake case\n$!velocityTool.leftPadZeros(str,n)\tpad sting with zero make str length at least n.\n$!velocityTool.date()\tThe current time
template.variable=${0}question.title{1}\tquestion title\tex:Two Sum\n${0}question.titleSlug{1}\tquestion title slug \tex:two-sum\n${0}question.frontendQuestionId{1}\tquestion serial number\n${0}question.content{1}\tquestion content\n${0}question.code{1}\tquestion code\n$!velocityTool.camelCaseName(str)\ttransform str big camel case\n$!velocityTool.smallCamelCaseName(str)\ttransform str small camel case\n$!velocityTool.snakeCaseName(str)\ttransform str snake case\n$!velocityTool.leftPadZeros(str,n)\tpad sting with zero make str length at least n.\n$!velocityTool.date()\tThe current time
tree.load=Please load questions first
tree.null=Questions returned are empty
tree.select=Please select a valid question in the list
2 changes: 1 addition & 1 deletion src/main/resources/i18n/info_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ report=\u5411\u63D2\u4EF6\u4F5C\u8005\u62A5\u544A
donate.info=\u6253\u8D4F
updata=leetcode editor\u65B0\u7248\u672C {0} \u53D1\u5E03,\u8BF7\u53CA\u65F6\u66F4\u65B0
user.email=\u60A8\u5C1A\u672A\u9A8C\u8BC1\u81EA\u5DF1\u7684\u5E10\u6237\n\u5728\u9A8C\u8BC1\u7535\u5B50\u90AE\u4EF6\u4E4B\u524D\uFF0C\u60A8\u65E0\u6CD5\u5C06\u4EE3\u7801\u63D0\u4EA4\u7ED9\u8BC4\u5224\u7CFB\u7EDF\u3002\n\u60A8\u53EF\u4EE5\u5728\u4E2A\u4EBA\u8D44\u6599\u9875\u9762\u4E2D\u91CD\u65B0\u53D1\u9001\u9A8C\u8BC1\u7535\u5B50\u90AE\u4EF6\u6216\u66F4\u6539\u7535\u5B50\u90AE\u4EF6\u3002
template.variable=${0}question.title{1}\t\u9898\u76EE\u6807\u9898\t\u793A\u4F8B:\u4E24\u6570\u4E4B\u548C\n${0}question.titleSlug{1}\t\u9898\u76EE\u6807\u8BB0\t\u793A\u4F8B:two-sum\n${0}question.frontendQuestionId{1}\t\u9898\u76EE\u7F16\u53F7\n${0}question.content{1}\t\u9898\u76EE\u63CF\u8FF0\n${0}question.code{1}\t\u9898\u76EE\u4EE3\u7801\n$!velocityTool.camelCaseName(str)\t\u8F6C\u6362\u5B57\u7B26\u4E3A\u9A7C\u5CF0\u6837\u5F0F\n$!velocityTool.snakeCaseName(str)\t\u8F6C\u6362\u5B57\u7B26\u4E3A\u86C7\u5F62\u6837\u5F0F\n$!velocityTool.leftPadZeros(str,n)\tpad sting with zero make str length at least n.\n$!velocityTool.date()\t\u83B7\u53D6\u5F53\u524D\u65F6\u95F4
template.variable=${0}question.title{1}\t\u9898\u76ee\u6807\u9898\t\u793a\u4f8b:\u4e24\u6570\u4e4b\u548c\n${0}question.titleSlug{1}\t\u9898\u76ee\u6807\u8bb0\t\u793a\u4f8b:two-sum\n${0}question.frontendQuestionId{1}\t\u9898\u76ee\u7f16\u53f7\n${0}question.content{1}\t\u9898\u76ee\u63cf\u8ff0\n${0}question.code{1}\t\u9898\u76ee\u4ee3\u7801\n$!velocityTool.camelCaseName(str)\t\u8f6c\u6362\u5b57\u7b26\u4e3a\u5927\u9a7c\u5cf0\u6837\u5f0f\uff08\u5f00\u5934\u5b57\u6bcd\u5927\u5199\uff09\n$!velocityTool.smallCamelCaseName(str)\t\u8f6c\u6362\u5b57\u7b26\u4e3a\u5c0f\u9a7c\u5cf0\u6837\u5f0f\uff08\u5f00\u5934\u5b57\u6bcd\u5c0f\u5199\uff09\n$!velocityTool.snakeCaseName(str)\t\u8f6c\u6362\u5b57\u7b26\u4e3a\u86c7\u5f62\u6837\u5f0f\n$!velocityTool.leftPadZeros(str,n)\t\u5728\u5b57\u7b26\u4e32\u7684\u5de6\u8fb9\u586b\u51450\uff0c\u4f7f\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u81f3\u5c11\u4e3an\n$!velocityTool.date()\t\u83b7\u53d6\u5f53\u524d\u65f6\u95f4
tree.load=\u8BF7\u5148\u52A0\u8F7D\u9898\u76EE
tree.null=\u83B7\u53D6\u9898\u76EE\u4E3A\u7A7A
tree.select=\u8BF7\u5728\u5217\u8868\u4E2D\u9009\u62E9\u4E00\u4E2A\u6709\u6548\u7684\u9898\u76EE